md5解密的网站不少,像cmd5.com,md5.com.cn,tmd5.com等等,不过都只能免费查单条记录,批量查询的话就要钱了,既然可以免费查询单条记录,那就程序实现自动提交去查询即可,其实就是程序模拟post提交。
选择的网站是md5.com.cn,效果还行,由于此网站对查询做了限制,如果同个IP连续查询过多记录,那么就会提示你,不让你继续查询了,大部分人应该可以通过断开网络重新连网,此时IP变了后就可以继续运行程序查询(需要把之前已经查到的删掉,不然每次都是查询前面几条记录了),大概一次可以查200多个吧,对于小批量查询的要求还是可以满足的。
选择的网站是md5.com.cn,效果还行,由于此网站对查询做了限制,如果同个IP连续查询过多记录,那么就会提示你,不让你继续查询了,大部分人应该可以通过断开网络重新连网,此时IP变了后就可以继续运行程序查询(需要把之前已经查到的删掉,不然每次都是查询前面几条记录了),大概一次可以查200多个吧,对于小批量查询的要求还是可以满足的。
查询结果:左边是md5加密的,右边是对应解密后的。
代码写的很粗糙,每次查询都是重新建立一个连接,没试过一个连接查询多个,应该还有很多优化空间。
程序需要的3个jar文件可在此处下载:http://download.csdn.net/detail/prstaxy/5326485
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
/**
* 功能:从md5.com.cn网站批量解密,一个IP可连续解密大概200个需更换IP 2013.5.2
*
* @author 枫轩缘
*/
public class Md5Reverse
{
public static List<String> hashList = new ArrayList<String>();
public static void main(String[] args)
{
readFile("E:\\p.txt");// 读入存储md5的文件(16位)
// GetMd5Rreverse("edc4019a607176b5");
for (String hash : hashList) {
GetMd5Rreverse(hash);// 遍历所有md5进行解密
// Thread.sleep(8000);
}
}
public static void readFile(String fileName)
{
File file = new File(fileName);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// System.out.println(tempString);
hashList.add(tempString);
}
reader.close();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (reader != null) {
try {
reader.close();
}
catch (IOException e1) {}
}
}
}
/**
* 功能:从md5.com.cn网站批量解密,一个IP可连续解密大概200个需更换IP
*
* @param hash 要进行解密的md5
*/
public static void GetMd5Rreverse(String hash)
{
HttpClient httpClient = new HttpClient();
String url = "http://md5.com.cn/md5reverse";
PostMethod postMethod = new PostMethod(url);
postMethod.setRequestHeader("Referer", "http://md5.com.cn/md5");
// 填入各个表单域的值
NameValuePair[] data = { new NameValuePair("md", hash),// md=edc4019a607176b5&submit=MD5+Crack
new NameValuePair("submit", "MD5+Crack") };
// 将表单的值放入postMethod中
postMethod.setRequestBody(data);
// 执行postMethod
int statusCode = 0;
try {
statusCode = httpClient.executeMethod(postMethod);
}
catch (HttpException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
// HttpClient对于要求接受后继服务的请求,象POST和PUT等不能自动处理转发
// 301或者302
if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY
|| statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
// 从头中取出转向的地址
Header locationHeader = postMethod.getResponseHeader("location");
String location = null;
if (locationHeader != null) {
location = locationHeader.getValue();
System.out.println("The page was redirected to:" + location);
}
else
System.out.println("Location field value is null.");
}
else {
// System.out.println(postMethod.getStatusLine());
String responseStr = "";
responseStr = postMethod.getResponseBodyAsString();
// System.out.println(responseStr);
int start = responseStr.indexOf("<b style=\"color:red;\">");// 注意转义
// ,md5解密结果在这2个html代码之间
int end = responseStr
.indexOf("</b><br/><span style=\"font-family:");
if (start != -1) {
System.out.println(hash + "\t"
+ responseStr.substring(start + 22, end));
writeResult(hash + "\t"
+ responseStr.substring(start + 22, end)
+ System.lineSeparator());
}
else {
System.out.println("无法查到结果!");
writeResult(hash);
}
}
postMethod.releaseConnection();
return;
}
public static void writeResult(String content)
{
try {
// 打开一个随机访问文件流,按读写方式
RandomAccessFile randomFile = new RandomAccessFile("E:\\r.txt","rw");
// 文件长度,字节数
long fileLength = randomFile.length();
// 将写文件指针移到文件尾。
randomFile.seek(fileLength);
randomFile.writeBytes(content);
randomFile.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}