// Class : DH Tools
// Version : 0.2
// (C) Doddy Hackman 2015
// Functions :
//
//public String toma(String link)
//public String tomar(String pagina, String data)
//public void savefile(String ruta, String texto)
//public String read_file(String ruta)
//public String console(String command)
//public String httpfinger(String target)
//public Integer response_code(String page)
//public ArrayList repes(ArrayList array)
//public ArrayList cortar(ArrayList array)
//public String regex(String code, String deaca, String hastaaca)
//public Boolean download(String url, File savefile)
//public String extract_file_by_url(String url)
//public String uri_split(String link, String opcion)
//public String md5_encode(String text)
//public String md5_file(String file)
//public String get_ip(String hostname)
//
package dhtools;
import java.io.*;
import java.net.*;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.security.*;
public class DH_Tools {
try {
nave.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
while ((re = leyendo.readLine()) != null) {
conte.append(re);
}
leyendo.close();
//
}
return conte.toString();
}
// Credits : Function based in http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
try {
URL url_now
= new URL(pagina
);
nave.setRequestMethod("POST");
nave.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
nave.setDoOutput(true);
send.writeBytes(data);
send.flush();
send.close();
while ((linea = leyendo.readLine()) != null) {
code.append(linea);
}
leyendo.close();
respuesta = code.toString();
//
}
return respuesta;
}
try {
archivo
= new File(ruta
);
if (!archivo.exists()) {
archivo.createNewFile();
}
escribir.write(texto);
escribir.flush();
escribir.close();
//
}
}
try {
Scanner leyendo
= new Scanner
(new FileReader(ruta
)); contenido = leyendo.next();
//
}
return contenido;
}
try {
proceso.waitFor();
while ((linea = leyendo.readLine()) != null) {
code.append(linea);
}
contenido = code.toString();
//
}
return contenido;
}
//http://www.mkyong.com/java/how-to-get-http-response-header-in-java/
try {
String server
= nave.
getHeaderField("Server"); String etag
= nave.
getHeaderField("ETag"); String content_length
= nave.
getHeaderField("Content-Length"); String expires
= nave.
getHeaderField("Expires"); String last_modified
= nave.
getHeaderField("Last-Modified"); String connection
= nave.
getHeaderField("Connection"); String powered
= nave.
getHeaderField("X-Powered-By"); String pragma
= nave.
getHeaderField("Pragma"); String cache_control
= nave.
getHeaderField("Cache-Control"); String date
= nave.
getHeaderField("Date"); String vary
= nave.
getHeaderField("Vary"); String content_type
= nave.
getHeaderField("Content-Type"); String accept_ranges
= nave.
getHeaderField("Accept-Ranges");
if (server != null) {
resultado += "[+] Server : " + server + "\n";
}
if (etag != null) {
resultado += "[+] E-tag : " + etag + "\n";
}
if (content_length != null) {
resultado += "[+] Content-Length : " + content_length + "\n";
}
if (expires != null) {
resultado += "[+] Expires : " + expires + "\n";
}
if (last_modified != null) {
resultado += "[+] Last Modified : " + last_modified + "\n";
}
if (connection != null) {
resultado += "[+] Connection : " + connection + "\n";
}
if (powered != null) {
resultado += "[+] Powered : " + powered + "\n";
}
if (pragma != null) {
resultado += "[+] Pragma : " + pragma + "\n";
}
if (cache_control != null) {
resultado += "[+] Cache control : " + cache_control + "\n";
}
if (date != null) {
resultado += "[+] Date : " + date + "\n";
}
if (vary != null) {
resultado += "[+] Vary : " + vary + "\n";
}
if (content_type != null) {
resultado += "[+] Content-Type : " + content_type + "\n";
}
if (accept_ranges != null) {
resultado += "[+] Accept Ranges : " + accept_ranges + "\n";
}
//
}
return resultado;
}
try {
nave2.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
response = nave2.getResponseCode();
response = 404;
}
return response;
}
Object[] listando
= array.
toArray(); for (Object item
: listando
) { if (array.indexOf(item) != array.lastIndexOf(item)) {
array.remove(array.lastIndexOf(item));
}
}
return array;
}
for (int i = 0; i < array.size(); i++) {
Pattern regex1 = null;
Matcher regex2 = null;
regex1 = Pattern.compile("(.*?)=(.*?)");
regex2 = regex1.matcher(code);
if (regex2.find()) {
array2.add(regex2.group(1) + "=");
}
}
return array2;
}
Pattern regex1 = null;
Matcher regex2 = null;
regex1 = Pattern.compile(deaca + "(.*?)" + hastaaca);
regex2 = regex1.matcher(code);
if (regex2.find()) {
resultado = regex2.group(1);
}
return resultado;
}
// Credits : Based on http://stackoverflow.com/questions/921262/how-to-download-and-save-a-file-from-internet-using-java
// Thanks to Brian Risk
try {
URL download_page
= new URL(url
); ReadableByteChannel down1 = Channels.newChannel(download_page.openStream());
down2.
getChannel().
transferFrom(down1,
0,
Long.
MAX_VALUE); down1.close();
down2.close();
return true;
return false;
}
}
return url.substring(url.lastIndexOf('/') + 1);
}
try {
if (opcion == "protocol") {
resultado = url.getProtocol();
} else if (opcion == "authority") {
resultado = url.getAuthority();
} else if (opcion == "host") {
resultado = url.getHost();
} else if (opcion == "port") {
resultado
= String.
valueOf(url.
getPort()); } else if (opcion == "path") {
resultado = url.getPath();
} else if (opcion == "query") {
resultado = url.getQuery();
} else if (opcion == "filename") {
resultado = url.getFile();
} else if (opcion == "ref") {
resultado = url.getRef();
} else {
resultado = "Error";
}
//
}
return resultado;
}
// Credits : Based on http://www.avajava.com/tutorials/lessons/how-do-i-generate-an-md5-digest-for-a-string.html
try {
generate.update(text.getBytes());
byte[] result = generate.digest();
for (byte line : result) {
string_now.
append(String.
format("%02x", line
& 0xff
)); }
//
}
return string_now.toString();
}
//Credits : Based on http://stackoverflow.com/questions/304268/getting-a-files-md5-checksum-in-java
// Thanks to
try {
byte[] bytes_now = new byte[1024];
int now_now = 0;
while ((now_now = file_now.read(bytes_now)) != -1) {
convert.update(bytes_now, 0, now_now);
};
byte[] converting = convert.digest();
for (int i = 0; i < converting.length; i++) {
result.
append(Integer.
toString((converting
[i
] & 0xff
) + 0x100,
16).
substring(1)); }
resultado = result.toString();
//
}
return resultado;
}
try {
resultado = getting_ip.getHostAddress();
//
}
return resultado;
}
}
// The End ?