破解(百度,网易,新浪,搜狐,QQ空间)图片防盗链
大家在连网易等站的图片的时候会发现,连接不了它的图片,因为对方有防盗链系统,现在发布一段JSP代码,用于破解防盗链,近期也会把ASP,PHP版的写出来
原理很简单,用流的形式读取回来后,再重新输出出去就OK了.利用的时候就用这样的格式就可以了
http://你的url地址/文件名.jsp?url=你要破解的图片防盗链地址
< %@page contentType="image/jpeg" import="java.io.OutputStream,java.io.InputStream,java.net.URL,java.net.URLConnection" language="java"%>< %
//response.reset();
try{
OutputStream os = response.getOutputStream();
String picPath = request.getQueryString();
picPath = picPath.substring(4,picPath.length());
URLConnection u = new URL(picPath).openConnection();
InputStream in = u.getInputStream();
if (null != in) {
int len;
byte[] b = new byte[1024];
while ((len = in.read(b)) != -1) { // 循环读取
os.write(b, 0, len); // 写入到输出流
}
os.flush();
in.close();
}
os.close();
out.clear();
out = pageContext.pushBody();
}catch(Exception e){
e.printStackTrace();
}
%>
//response.reset();
try{
OutputStream os = response.getOutputStream();
String picPath = request.getQueryString();
picPath = picPath.substring(4,picPath.length());
URLConnection u = new URL(picPath).openConnection();
InputStream in = u.getInputStream();
if (null != in) {
int len;
byte[] b = new byte[1024];
while ((len = in.read(b)) != -1) { // 循环读取
os.write(b, 0, len); // 写入到输出流
}
os.flush();
in.close();
}
os.close();
out.clear();
out = pageContext.pushBody();
}catch(Exception e){
e.printStackTrace();
}
%>