百度网盘上传

2074天前 · 分享 · 1031次阅读

在控件安装情况下,文件以分片形式上传
请求如下:

POST /rest/2.0/pcs/file?method=upload&app_id=250528&type=tmpfile&dir=%2F/&filename=**X** HTTP/1.1
Cookie: BDUSS=**pansec_X**
Accept: text/*
Content-Type: multipart/form-data; boundary=----------KM7ei4Ef1gL6ae0ei4gL6GI3GI3gL6
User-Agent: netdisk;2.0.0.4;PC;PC-Windows;10.0.17763;uploadplugin
Connection: Keep-Alive
Pragma: no-cache
Host: c.pcs.baidu.com
Cache-Control: no-cache
Content-Length: **X**

------------KM7ei4Ef1gL6ae0ei4gL6GI3GI3gL6
Content-Disposition: form-data; name="Filename"

------------KM7ei4Ef1gL6ae0ei4gL6GI3GI3gL6
Content-Disposition: form-data; name="Filedata"; filename=""
Content-Type: application/octet-stream
**...binary...**

其中**包含起来的地方为个人信息和提交信息,其中:

  • filename为32位大写的字母与数字组合 暂不知产生方法,也许是随机的
  • BDUSS实际上这里和通常使用的值不一样,这个值通过查看网页源代码可以看到,为XDUSS值
  • Content-Length会自动决定
  • 通过multipart/form-data提交的二进制数据分片大小为4M

返回如下:

HTTP/1.1 200 OK
Content-Type: text/html;charset=utf8
Connection: keep-alive
x-bs-client-ip: **X**
x-bs-request-id: **X**
x-bs-file-size: 4194304
Content-MD5: **X**
x-bs-meta-crc32: **X**
x-poms-part-key: **X**
x-bs-version: **X**
Vary: Accept-Encoding
Server: POMS/CloudUI 1.0
Content-Length: **X**

{"md5":"**X**","request_id":**X**}

其中x-bs-client-ip和x-bs-request-id为base64编码,解码后内容形式如下:
*.*.*.* 为你的出口/公网ip
*.*.*.*:*:*:201*-0*-* *:*:* 为内网ip+port+request_id+时间
x-bs-file-size为分片大小,一般是4M
Content-MD5和即为分片的md5,和返回的值一致
x-bs-meta-crc32似乎与我在电脑上计算的CRC32值不一致
x-poms-part-key和x-bs-version一致 32位数字字母小写组合

分片上传返回的md5在全部分片上传结束之后,通过下面这个接口组合成完整的文件

POST /api/create?a=commit&norename&clienttype=6&version=2.0.0.4 HTTP/1.1
Cookie: BDUSS=*
Connection: keep-alive
X-Requested-With: XMLHttpRequest
User-Agent: netdisk;2.0.0.4;PC;PC-Windows;10.0.17763;uploadplugin
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Language: zh-CN,zh;q=0.8
Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3
Host: pan.baidu.com
Cache-Control: no-cache
Content-Length: 266

path=//*&isdir=0&size=13729324&block_list=["","","",""]&method=POST

其中path为网盘路径,根目录则是//+文件名 size是文件总大小,block_list包含一个list,依次是md5值。
最后是浏览器请求了这个,似乎是刷新作用

GET /statistics?clienttype=0&version=v5&op=webupload&type=uploadSuccess&uk=*&product=pan&from=NativeUploader&detailKey=success&filesize=文件大小&is_member=0&success=1&uploadStyle=0&averageSpeed=0&filePath=本地路径&diskPath=/&file={"name":"文件名","type":"文件后缀包括点","server_path":"网盘路径根目录为/","progress":0,"size":"文件大小","path":"本地路径","dir":0,"status":3,"index":2,"resume":true} 
HTTP/1.1
Host: update.pan.baidu.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Accept: image/webp,image/*,*/*;q=0.8
Referer: https://pan.baidu.com/disk/home?
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: zh-CN,zh;q=0.8
Cookie: *
👍 0

none

最后修改于2074天前

评论

贴吧 狗头 原神 小黄脸
收起

贴吧

狗头

原神

小黄脸

目录

avatar

未末

迷失

126

文章数

275

评论数

7

分类