send
Grupo de Telegram
play_arrow
Este sitio utiliza cookies propias y de terceros. Si continúa navegando consideramos que acepta el uso de cookies. OK Más Información.

[Java] Class DH Tools 0.2

  • 0 Respuestas
  • 1555 Vistas

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado BigBear

  • *
  • Underc0der
  • Mensajes: 543
  • Actividad:
    0%
  • Reputación 3
    • Ver Perfil
« en: Enero 15, 2016, 12:22:38 pm »
Mi primer clase en Java , se llama DH Tools y tiene las siguientes opciones :

  • Realizar una peticion GET y guardar el contenido
  • Realizar una peticion POST y guardar el contenido
  • Crear o escribir archivos
  • Leer archivos
  • Ejecutar comandos y leer su respuesta
  • HTTP FingerPrinting
  • Leer el codigo de respuesta de una URL
  • Borrar repetidos en un ArrayList
  • Cortar las URL en un ArrayList a partir del query
  • Split casero xD
  • Descargar archivos
  • Capturar el archivo de una URL
  • URI Split
  • MD5 Encode
  • MD5 File
  • Get IP


El codigo de la clase :

Código: Java
  1. // Class : DH Tools
  2. // Version : 0.2
  3. // (C) Doddy Hackman 2015
  4. // Functions :
  5. //
  6. //public String toma(String link)
  7. //public String tomar(String pagina, String data)
  8. //public void savefile(String ruta, String texto)
  9. //public String read_file(String ruta)
  10. //public String console(String command)
  11. //public String httpfinger(String target)
  12. //public Integer response_code(String page)
  13. //public ArrayList repes(ArrayList array)
  14. //public ArrayList cortar(ArrayList array)
  15. //public String regex(String code, String deaca, String hastaaca)
  16. //public Boolean download(String url, File savefile)
  17. //public String extract_file_by_url(String url)
  18. //public String uri_split(String link, String opcion)
  19. //public String md5_encode(String text)
  20. //public String md5_file(String file)
  21. //public String get_ip(String hostname)
  22. //
  23. package dhtools;
  24.  
  25. import java.io.*;
  26. import java.net.*;
  27. import java.nio.channels.Channels;
  28. import java.nio.channels.ReadableByteChannel;
  29. import java.util.ArrayList;
  30. import java.util.Scanner;
  31. import java.util.regex.Matcher;
  32. import java.util.regex.Pattern;
  33. import java.security.*;
  34.  
  35. public class DH_Tools {
  36.  
  37.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login toma(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login link) {
  38.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login re;
  39.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login conte = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(40);
  40.         try {
  41.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login url = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(link);
  42.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login nave = url.openConnection();
  43.             nave.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
  44.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login leyendo = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(
  45.                     new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(nave.getInputStream()));
  46.             while ((re = leyendo.readLine()) != null) {
  47.                 conte.append(re);
  48.             }
  49.             leyendo.close();
  50.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  51.             //
  52.         }
  53.         return conte.toString();
  54.     }
  55.  
  56.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login tomar(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login pagina, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login data) {
  57.         // Credits : Function based in http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
  58.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login respuesta = "";
  59.  
  60.         try {
  61.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login url_now = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(pagina);
  62.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login nave = (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login) url_now.openConnection();
  63.  
  64.             nave.setRequestMethod("POST");
  65.             nave.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
  66.  
  67.             nave.setDoOutput(true);
  68.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login send = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(nave.getOutputStream());
  69.             send.writeBytes(data);
  70.             send.flush();
  71.             send.close();
  72.  
  73.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login leyendo = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(nave.getInputStream()));
  74.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login code = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  75.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login linea;
  76.  
  77.             while ((linea = leyendo.readLine()) != null) {
  78.                 code.append(linea);
  79.             }
  80.             leyendo.close();
  81.             respuesta = code.toString();
  82.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  83.             //
  84.         }
  85.         return respuesta;
  86.     }
  87.  
  88.     public void savefile(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ruta, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login texto) {
  89.  
  90.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login escribir = null;
  91.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login archivo = null;
  92.  
  93.         try {
  94.  
  95.             archivo = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(ruta);
  96.  
  97.             if (!archivo.exists()) {
  98.                 archivo.createNewFile();
  99.             }
  100.  
  101.             escribir = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(archivo, true);
  102.             escribir.write(texto);
  103.             escribir.flush();
  104.             escribir.close();
  105.  
  106.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  107.             //
  108.         }
  109.     }
  110.  
  111.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login read_file(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login ruta) {
  112.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login contenido = null;
  113.         try {
  114.             Scanner leyendo = new Scanner(new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(ruta));
  115.             contenido = leyendo.next();
  116.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  117.             //
  118.         }
  119.         return contenido;
  120.     }
  121.  
  122.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login console(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login command) {
  123.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login contenido = null;
  124.         try {
  125.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login proceso = You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.getRuntime().exec("cmd /c " + command);
  126.             proceso.waitFor();
  127.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login leyendo = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(
  128.                     new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(proceso.getInputStream()));
  129.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login linea;
  130.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login code = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  131.             while ((linea = leyendo.readLine()) != null) {
  132.                 code.append(linea);
  133.             }
  134.             contenido = code.toString();
  135.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  136.             //
  137.         }
  138.         return contenido;
  139.     }
  140.  
  141.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login httpfinger(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login target) {
  142.  
  143.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login resultado = "";
  144.  
  145.         //http://www.mkyong.com/java/how-to-get-http-response-header-in-java/
  146.         try {
  147.  
  148.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login page = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(target);
  149.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login nave = page.openConnection();
  150.  
  151.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login server = nave.getHeaderField("Server");
  152.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login etag = nave.getHeaderField("ETag");
  153.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login content_length = nave.getHeaderField("Content-Length");
  154.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login expires = nave.getHeaderField("Expires");
  155.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login last_modified = nave.getHeaderField("Last-Modified");
  156.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login connection = nave.getHeaderField("Connection");
  157.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login powered = nave.getHeaderField("X-Powered-By");
  158.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login pragma = nave.getHeaderField("Pragma");
  159.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login cache_control = nave.getHeaderField("Cache-Control");
  160.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login date = nave.getHeaderField("Date");
  161.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login vary = nave.getHeaderField("Vary");
  162.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login content_type = nave.getHeaderField("Content-Type");
  163.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login accept_ranges = nave.getHeaderField("Accept-Ranges");
  164.  
  165.             if (server != null) {
  166.                 resultado += "[+] Server : " + server + "\n";
  167.             }
  168.             if (etag != null) {
  169.                 resultado += "[+] E-tag : " + etag + "\n";
  170.             }
  171.             if (content_length != null) {
  172.                 resultado += "[+] Content-Length : " + content_length + "\n";
  173.             }
  174.  
  175.             if (expires != null) {
  176.                 resultado += "[+] Expires : " + expires + "\n";
  177.             }
  178.  
  179.             if (last_modified != null) {
  180.                 resultado += "[+] Last Modified : " + last_modified + "\n";
  181.             }
  182.  
  183.             if (connection != null) {
  184.                 resultado += "[+] Connection : " + connection + "\n";
  185.             }
  186.  
  187.             if (powered != null) {
  188.                 resultado += "[+] Powered : " + powered + "\n";
  189.             }
  190.  
  191.             if (pragma != null) {
  192.                 resultado += "[+] Pragma : " + pragma + "\n";
  193.             }
  194.  
  195.             if (cache_control != null) {
  196.                 resultado += "[+] Cache control : " + cache_control + "\n";
  197.             }
  198.  
  199.             if (date != null) {
  200.                 resultado += "[+] Date : " + date + "\n";
  201.             }
  202.             if (vary != null) {
  203.                 resultado += "[+] Vary : " + vary + "\n";
  204.             }
  205.             if (content_type != null) {
  206.                 resultado += "[+] Content-Type : " + content_type + "\n";
  207.             }
  208.             if (accept_ranges != null) {
  209.                 resultado += "[+] Accept Ranges : " + accept_ranges + "\n";
  210.             }
  211.  
  212.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  213.             //
  214.         }
  215.  
  216.         return resultado;
  217.  
  218.     }
  219.  
  220.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login response_code(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login page) {
  221.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login response = 0;
  222.         try {
  223.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login url = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(page);
  224.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login nave1 = url.openConnection();
  225.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login nave2 = (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login) nave1;
  226.             nave2.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
  227.             response = nave2.getResponseCode();
  228.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  229.             response = 404;
  230.         }
  231.         return response;
  232.     }
  233.  
  234.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login repes(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login array) {
  235.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login[] listando = array.toArray();
  236.         for (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login item : listando) {
  237.             if (array.indexOf(item) != array.lastIndexOf(item)) {
  238.                 array.remove(array.lastIndexOf(item));
  239.             }
  240.         }
  241.         return array;
  242.     }
  243.  
  244.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login cortar(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login array) {
  245.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login array2 = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  246.         for (int i = 0; i < array.size(); i++) {
  247.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login code = (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login) array.get(i);
  248.             Pattern regex1 = null;
  249.             Matcher regex2 = null;
  250.             regex1 = Pattern.compile("(.*?)=(.*?)");
  251.             regex2 = regex1.matcher(code);
  252.             if (regex2.find()) {
  253.                 array2.add(regex2.group(1) + "=");
  254.             }
  255.         }
  256.         return array2;
  257.     }
  258.  
  259.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login regex(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login code, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login deaca, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login hastaaca) {
  260.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login resultado = "";
  261.         Pattern regex1 = null;
  262.         Matcher regex2 = null;
  263.         regex1 = Pattern.compile(deaca + "(.*?)" + hastaaca);
  264.         regex2 = regex1.matcher(code);
  265.         if (regex2.find()) {
  266.             resultado = regex2.group(1);
  267.         }
  268.         return resultado;
  269.     }
  270.  
  271.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login download(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login url, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login savefile) {
  272.         // Credits : Based on http://stackoverflow.com/questions/921262/how-to-download-and-save-a-file-from-internet-using-java
  273.         // Thanks to Brian Risk
  274.         try {
  275.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login download_page = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(url);
  276.             ReadableByteChannel down1 = Channels.newChannel(download_page.openStream());
  277.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login down2 = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(savefile);
  278.             down2.getChannel().transferFrom(down1, 0, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.MAX_VALUE);
  279.             down1.close();
  280.             down2.close();
  281.             return true;
  282.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  283.             return false;
  284.         }
  285.     }
  286.  
  287.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login extract_file_by_url(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login url) {
  288.         return url.substring(url.lastIndexOf('/') + 1);
  289.     }
  290.  
  291.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login uri_split(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login link, You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login opcion) {
  292.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login resultado = "";
  293.         try {
  294.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login url = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(link);
  295.             if (opcion == "protocol") {
  296.                 resultado = url.getProtocol();
  297.             } else if (opcion == "authority") {
  298.                 resultado = url.getAuthority();
  299.             } else if (opcion == "host") {
  300.                 resultado = url.getHost();
  301.             } else if (opcion == "port") {
  302.                 resultado = You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.valueOf(url.getPort());
  303.             } else if (opcion == "path") {
  304.                 resultado = url.getPath();
  305.             } else if (opcion == "query") {
  306.                 resultado = url.getQuery();
  307.             } else if (opcion == "filename") {
  308.                 resultado = url.getFile();
  309.             } else if (opcion == "ref") {
  310.                 resultado = url.getRef();
  311.             } else {
  312.                 resultado = "Error";
  313.             }
  314.  
  315.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  316.             //
  317.         }
  318.         return resultado;
  319.     }
  320.  
  321.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login md5_encode(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login text) {
  322.         // Credits : Based on http://www.avajava.com/tutorials/lessons/how-do-i-generate-an-md5-digest-for-a-string.html
  323.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login string_now = null;
  324.         try {
  325.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login generate = You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.getInstance("MD5");
  326.             generate.update(text.getBytes());
  327.             byte[] result = generate.digest();
  328.             string_now = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  329.             for (byte line : result) {
  330.                 string_now.append(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.format("%02x", line & 0xff));
  331.             }
  332.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  333.             //
  334.         }
  335.         return string_now.toString();
  336.     }
  337.  
  338.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login md5_file(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login file) {
  339.         //Credits : Based on http://stackoverflow.com/questions/304268/getting-a-files-md5-checksum-in-java
  340.         // Thanks to
  341.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login resultado = "";
  342.         try {
  343.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login convert = You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.getInstance("MD5");
  344.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login file_now = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login(file);
  345.  
  346.             byte[] bytes_now = new byte[1024];
  347.  
  348.             int now_now = 0;
  349.             while ((now_now = file_now.read(bytes_now)) != -1) {
  350.                 convert.update(bytes_now, 0, now_now);
  351.             };
  352.             byte[] converting = convert.digest();
  353.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login result = new You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login();
  354.             for (int i = 0; i < converting.length; i++) {
  355.                 result.append(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.toString((converting[i] & 0xff) + 0x100, 16).substring(1));
  356.             }
  357.             resultado = result.toString();
  358.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  359.             //
  360.         }
  361.         return resultado;
  362.     }
  363.  
  364.     public You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login get_ip(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login hostname) {
  365.         You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login resultado = "";
  366.         try {
  367.             You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login getting_ip = You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login.getByName(hostname);
  368.             resultado = getting_ip.getHostAddress();
  369.         } catch (You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login e) {
  370.             //
  371.         }
  372.         return resultado;
  373.     }
  374. }
  375.  
  376. // The End ?
  377.  

Ejemplos de uso :

Código: Java
  1. package dhtools;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login[] args) {
  9.         DH_Tools tools = new DH_Tools();
  10.         //String codigo = tools.toma("http://localhost/");
  11.         //String codigo = tools.tomar("http://localhost/login.php", "usuario=test&password=dsdsads&control=Login");
  12.         //tools.savefile("c:/xampp/texto.txt","texto");
  13.         //String codigo = tools.read_file("c:/xampp/texto.txt");
  14.         //String codigo = tools.console("ver");
  15.         //String codigo = tools.httpfinger("http://www.petardas.com");
  16.         /*
  17.          ArrayList array = new ArrayList();
  18.          Collections.addAll(array, "http://localhost/sql.php?id=dsaadsds", "b", "http://localhost/sql.php?id=dsaadsds", "c");
  19.          ArrayList array2 = tools.repes(tools.cortar(array));
  20.          for (int i = 0; i < array2.size(); i++) {
  21.          System.out.println(array2.get(i));
  22.          }
  23.          */
  24.         //System.out.println(tools.regex("1sadasdsa2","1","2"));
  25.         //System.out.println(tools.response_code("http://www.petardas.com/"));
  26.         /*
  27.          File savefile = new File("c:/xampp/mierda.avi");
  28.          if(tools.download("http://localhost/test.avi",savefile)) {
  29.          System.out.println("yeah");
  30.          }
  31.          */
  32.  
  33.         //System.out.println(tools.extract_file_by_url("http://localhost/dsaads/dsadsads/index.php"));
  34.         //System.out.println(tools.uri_split("http://localhost/index.php?id=dadsdsa","query"));
  35.         //System.out.println(tools.md5_encode("123"));
  36.         //System.out.println(tools.md5_file("c:\\xampp\\texto.txt"));
  37.         //System.out.println(tools.get_ip("www.petardas.com"));
  38.     }
  39.  
  40. }
  41.  

Eso seria todo.
« Última modificación: Febrero 27, 2016, 12:37:14 pm por ANTRAX »

 

¿Te gustó el post? COMPARTILO!



[Video Curso] Iniciacion a Java por DesarrolloWeb y EscuelaIT Mayo 2014

Iniciado por graphixx

Respuestas: 3
Vistas: 1396
Último mensaje Febrero 23, 2015, 10:13:28 am
por Hu3c0
Java Extremo [Video Cursos Completos] [Español] [ISO] 2009

Iniciado por graphixx

Respuestas: 9
Vistas: 4169
Último mensaje Diciembre 04, 2017, 02:36:34 am
por graphixx
Como compilar programas Java en la consola de comandos de Windows

Iniciado por tar3kw0rm3d

Respuestas: 2
Vistas: 2098
Último mensaje Junio 04, 2013, 02:55:07 pm
por tar3kw0rm3d
[LIBRO] Programación avanzada en Java - Sonia Jaramillo Valbuena

Iniciado por graphixx

Respuestas: 1
Vistas: 2327
Último mensaje Noviembre 07, 2017, 12:34:40 pm
por K0m0dr3x
[Java] Chat utilizando WebSockets con JavaEE y JavaFx

Iniciado por coke951

Respuestas: 3
Vistas: 2674
Último mensaje Diciembre 23, 2016, 10:23:24 pm
por coke951