突破防盗链。
利用http://www.rayfile.com/zh-cn/做上传音乐实例
http://7uus.com/up/   php版本
http://www.111ttt.com/mp3/  ASP版本<?
$mr=$_GET['r'];
function vita_get_url_content($url) {
$ch = curl_init();
$User_Agent = "'http://www.rayfile.com/zh-cn/files/'.$mr";
$Referer_Url = 'http://www.rayfile.com/';
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, $User_Agent); 
curl_setopt ($ch, CURLOPT_REFERER, $Referer_Url); 
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
return $file_contents;
}
if ($mr){
$url="http://www.rayfile.com/zh-cn/files/".$mr;
$file=vita_get_url_content($url);
$regx='<div class="btn_indown_zh-cn"><a href="([^\<]*)"></a></div>';
eregi($regx,$file,$rg);
$file=vita_get_url_content($rg[1]);
$rf="downloads_url = \['([^\[]*)'\]";
eregi($rf,$file,$dz);
}
Header("HTTP/1.1 303 See Other");
header("location: $dz[1]");
?> 
调用
http://lovecmp.com/s/?r=c97ce4ca-43ef-11df-ad27-0015c55db73d
apache   Rewrite规则
RewriteEngine On
RewriteBase /
RewriteRule ^s/(.*)/cmp\.mp3$ s/index.php\?r=$1
http://lovecmp.com/s/f0fe148a-6828-11df-ba0f-0015c55db73d/cmp.mp3
能输出地址
http://cachefile28.rayfile.com/zh-cn/download/2ab018a75ea13c42a90bd3e0d4290d08/You%20Are%20My%20Sunshine.mp3但是防止盗链
我真的很苦闷为啥人家的可以 俺的就不可以
http://mp3.7uus.com/nb/beda30e6-f38a-11de-bfcf-0014221b798a/7uus.mp3
http://i.111ttt.com/up_file/ccd1fb6b-682f-11df-b6d2-0015c55db73d/QQMC.comduibuqiwo.mp3
抓包测试了一下
http://lovecmp.com/s/72f9f54a-6826-11df-9813-0015c55db73d/cmp.mp3
不能下载的情况:
(Request-Line)        GET /zh-cn/download/946dfb2881cc22465418371f6e700f3a/duibuqiwo.mp3 HTTP/1.1
Host        cachefile34.rayfile.com
User-Agent        Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept        text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language        zh-cn,zh;q=0.5
Accept-Encoding        gzip,deflate
Accept-Charset        GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive        115
Connection        keep-alive
Referer        http://bbs.blueidea.com/forum-2-1.html
可以下载的情况:
(Request-Line)        GET /zh-cn/download/946dfb2881cc22465418371f6e700f3a/duibuqiwo.mp3 HTTP/1.1
Host        cachefile34.rayfile.com
User-Agent        Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept        text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language        zh-cn,zh;q=0.5
Accept-Encoding        gzip,deflate
Accept-Charset        GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive        115
Connection        keep-alive
Referer        http://bbs.blueidea.com/forum-2-1.html
Cookie        ROXCDNKEY=6dc6; lzstat_uv=3137015631449830414|1095523; __utma=115050116.1884381382.1274830038.1274830038.1274830038.1; __utmb=115050116; __utmz=115050116.1274830043.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
区别就在:
Cookie        ROXCDNKEY=6dc6; lzstat_uv=3137015631449830414|1095523; __utma=115050116.1884381382.1274830038.1274830038.1274830038.1; __utmb=115050116; __utmz=115050116.1274830043.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
这应该就是为什么重启电脑,或者换一个浏览器就不能下载的原因
在进入他们页面时,会写入一个Cookie,开始以为是Session会搞鬼,测试了不会,重新打开浏览器还可以下载
说明还是Cookie的问题,Cookie可以设置在一定时间保存在电脑
所以你试一下,提取他们的Cookie,然后写入,它会随头一起发出去
用IECooliesView.exe工具查了一下,核心地方就在Cookie这个位置:
rayfile.com/zh-cn/download/946dfb2881cc22465418371f6e700f3a/
保存了这样一个Cookie值:
ROXCDNKEY=6dc6
有效时间正好是一天这个可能就是,一天变一次的验证值
上面的区别中的Cookie里也有这个:
Cookie        ROXCDNKEY=6dc6;刚刚用工具修改了一下那个值就不能下,所以这就是问题所在想办法把这个读出来再放入头送出去,或者放在地址里送出去
求高手帮忙

解决方案 »

  1.   

    curl 里面可以设置 cookie 的保存位置 的 查下手册吧
      

  2.   

             curl_setopt($s,CURLOPT_COOKIEJAR,$this->_cookieFileLocation);
             curl_setopt($s,CURLOPT_COOKIEFILE,$this->_cookieFileLocation);
      

  3.   

    老兄可以具体点吗?我按照你这修改测试还是不行,要定义cookie存储文件夹吧。
    期待你的回答,function vita_get_url_content($url) {
    $ch = curl_init();
    $User_Agent = "'http://www.rayfile.com/zh-cn/files/'.$mr";
    $Referer_Url = 'http://www.rayfile.com/';
    $timeout = 5;
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_USERAGENT, $User_Agent); 
    curl_setopt ($ch, CURLOPT_REFERER, $Referer_Url); 
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    curl_close($ch);
    return $file_contents;
    }
    最好能在这里加好。
      

  4.   


    $cookie_file = dirname(__FILE__)."/cookie_".md5(basename(__FILE__)).".txt";
    curl_setopt   ($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookie_file']); 
    curl_setopt   ($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookie_file']);
    我这样好像不行
      

  5.   

    cookie要实时获取,实时更新。