使用Python对dbank网盘地址解析

October 23, 2014

工作研究,抓包研究了下,随手写了段Python代码:

# coding:utf-8

# Author: GeekGao

# Date: 2014-10-23

"""
   decrypt_url(downloadurl, encrykey)参数来自dbank下载页,动态生成且有时效限制;
"""


def decrypt_url(downloadurl, encrykey):
   import base64
   import md5
   decode_str = base64.decodestring(downloadurl)
   sub = encrykey[0:2]
   if sub == "ea":
       d = decode_str
   elif sub == "eb":
       raise NotImplementedError() #另一个解密过程,业务用不到就不去实现了
   elif sub == "ed":
       md5s = md5.new(encrykey).hexdigest()
       d = b(decode_str, md5s)
   else:
       d = sub
   return d


def b(d, e):
   h = 0
   g = ””
   k = len(e)
   f = len(d)

   while h < f:
       j = ord(d[h]) ^ ord(e[h % k])
       g += chr(j)
       h = h + 1
   return g


if __name__ == __main__:
   url = ("""WkxEQgpKF1JVHlMBV1cIF1AMWk0BDBJXVQoAU0lE"""
           """cAAXAXIXciEdcwwVdiUTASAcdlsSIyBGJ3gXFQVRWQcIV"""
           """gJTA0IGAkhODhZeXgcfCwQCVwZWVVZQDAFRR0FbBVNRUQ9"""
           """RUVJDTQsBBgVSBw9bWBUKR19UUVEXCFNRGV9TGw0AHkAPAE"""
           """NURlBUCkVCWl4IFQJCCwFeQ1VKWA==""")
   print decrypt_url(url,"ed84772502")

· EOF ·