原創js腳本實現百度網盤任意文件強制下載


代碼:

 

//get file list data
var data=require("system-core:context/context.js").instanceForSystem.getList().listView.listsData;

//calculate sign
function base64Encode(r){var t,e,a,c,n,o,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(a=r.length,e=0,t="";a>e;){if(c=255&r.charCodeAt(e++),e==a){t+=h.charAt(c>>2),t+=h.charAt((3&c)<<4),t+="==";break}if(n=r.charCodeAt(e++),e==a){t+=h.charAt(c>>2),t+=h.charAt((3&c)<<4|(240&n)>>4),t+=h.charAt((15&n)<<2),t+="=";break}o=r.charCodeAt(e++),t+=h.charAt(c>>2),t+=h.charAt((3&c)<<4|(240&n)>>4),t+=h.charAt((15&n)<<2|(192&o)>>6),t+=h.charAt(63&o)}return t}
function u(j,r){var a=[];var p=[];var o="";var v=j.length;for(var q=0;q<256;q++){a[q]=j.substr((q%v),1).charCodeAt(0);p[q]=q}for(var u=q=0;q<256;q++){u=(u+p[q]+a[q])%256;var t=p[q];p[q]=p[u];p[u]=t}for(var i=u=q=0;q<r.length;q++){i=(i+1)%256;u=(u+p[i])%256;var t=p[i];p[i]=p[u];p[u]=t;k=p[((p[i]+p[u])%256)];o+=String.fromCharCode(r.charCodeAt(q)^k)}return o}
var sign=base64Encode(u(yunData.sign5, yunData.sign1)).replace(/=/g,"%3D").replace(/\+/g,"%2B");

//downloader
function down(index){$.ajax({type:"GET",url:"/api/download?sign="+sign+"&timestamp="+yunData.timestamp+"&fidlist=%5B"+data[index-1].fs_id+"%5D",success:function(d){console.warn(d.dlink
[0].dlink);}});}

 

 

 

用法:

 

1.進入網盤文件目錄。

2.F12打開調試工具將代碼粘貼到控制台並回車。

3.在控制台輸入down(文件序號)命令,回車即可得到文件的下載地址,可復制到任何下載工具滿速下載。

“文件序號”對應文件目錄列表,下載第一個文件就輸入down(1),第二個文件就輸入down(2),依此類推。注意括號是英文括號。

 

原理:

下載鏈接獲取接口:

通過監聽與其服務器交互的請求數據分析得到獲取下載鏈接的接口,在源文件中搜索發現了接口的調用過程。

接口:/api/download?sign=***&timestamp=***&fidlist=%5B***%5D"

在去除了一些不影響調用結果的參數后得知調用接口主要需要以下參數:

  1. sign(用戶身份)
  2. timestamp(時間戳)
  3. fs_id(文件標識碼)

sign的計算:

算法在源文件中可以發現,“var sign=”搜索全部文件即可發現算法代碼,將其復制調用就能計算出sign的值。

timestamp的獲取:

該值保存在全局變量中,直接yunData.timestamp就可以拿到。

fs_id的獲取:

調用“context.js”腳本就可以拿到文件列表,文件列表中保存了當前目錄所有文件的fs_id。

var data=require("system-core:context/context.js").instanceForSystem.getList().listView.listsData;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM