Fdream's Blog
专注于WEB前端开发
Powered by Google

还原百度MP3真实地址

9 多云 2009-1
Fdream 发表于 Ajax Web, 已被阅读 1634 次, 评论 0 条
关键词:javascript
[ 阅读字体大小: ]

纯属无聊,本来只是想写个豆瓣的插件,看到歌曲列表以后就可以在线试听或者下载,不过不能直接从搜索结果列表拿到mp3或者wma的真实地址,只能进去下载页面分析。

不过下载页面的地址的加密倒是简单,很容易就发现了URL密文和明文的对应关系,再稍微看一下JavaScript,就知道怎么还原了。还原方法如下(还是JavaScript版本的):

参考代码: [复制代码] [保存代码]

//48-0, 65-A, 97-a
var CHARACTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';

function decode(url, offset) {
    var l = url.length;
    var s = '', idx, ch;
    for (var i = 0; i < l; i++) {
        ch = url.charAt(i);
        if (/[A-Za-z0-9]/.test(ch)) {
            idx = CHARACTERS.indexOf(ch) - offset;
            if (idx < 0) {
                idx += 62
            }
            ch = CHARACTERS.charAt(idx);
        }
        s += ch;
    }
    return s;
}

var u = 'jvvr://yyy.mcmctkpi.eqo/wrnqcf/422A.34.39_32.33.59_5B79.or5';
//var u = 's440://E0xyn.nyx53tnn.nzx.ny/C/JJH.x0E';

var hp = 43 // s.indexOf('h');
if(u.indexOf(':') == 3){
    hp = 41; //s.indexOf('f');
}
var o = CHARACTERS.indexOf(u.charAt(0)) - hp;

alert(decode(u, o));

Related articles 您可能对这些文章也感兴趣:
Related comments 与该文相关的评论:(我也想说几句)
Add a comment 我来说两句: 
禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
表  情
arrow
用户名:   密码:  (匿名可不写) 同时注册?
验证码:   看不清?换个图片  看不清楚?换个图片

 
Copyright © 2005-2008,Fdream All Rights Reserved
Processed in 1.109375 second(s) , unknow queries
Powered by OWord V0.1, Even Not Alpha
(此博客程序为半成品,请勿索取,以免给您的心灵造成创伤^_^)
鄂ICP备05026031号