Skip to content

fix(lanzou): support acw_sc__v2 and secondary validation for download link#1379

Merged
jyxjjj merged 7 commits intoOpenListTeam:mainfrom
HG-ha:main
Sep 30, 2025
Merged

fix(lanzou): support acw_sc__v2 and secondary validation for download link#1379
jyxjjj merged 7 commits intoOpenListTeam:mainfrom
HG-ha:main

Conversation

@HG-ha
Copy link
Copy Markdown
Contributor

@HG-ha HG-ha commented Sep 28, 2025

Description / 描述

drivers/lanzou/util.gogetFilesByShareUrl 函数中,增加了对获取最终下载链接时 acw_sc__v2 验证的处理。

当请求下载页面以获取302重定向时,如果服务器返回的是包含 acw_sc__v2 JavaScript 验证的页面而不是重定向,代码现在会:

  1. 解析响应体,计算出 acw_sc__v2 的值。
  2. 将计算出的值作为 Cookie,重新发起请求。
  3. 此过程在一个循环中进行,最多重试3次,以确保能成功获取到真实的下载链接。

Motivation and Context / 背景

蓝奏云更新了其安全策略,在获取最终下载链接的步骤中也加入了 acw_sc__v2 验证。这导致在没有相应处理的情况下,无法获取到真实的下载地址,从而导致解析失败。

此更改修复了该问题,使程序能够正确处理这种验证,保证蓝奏云分享链接解析功能的稳定性。

  • alist输出
image
  • 蓝奏云真实请求
image

Closes #XXXX

Relates to #XXXX

How Has This Been Tested? / 测试

通过对触发了 acw_sc__v2 验证的蓝奏云文件分享链接进行实际测试,验证了修改后的代码可以成功绕过验证并获取到正确的最终下载地址。

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it’s needed).
    我已相应更新了相关仓库(若适用)。

在最新的蓝奏云解析中,最后重定向获取真实地址时也需要添加acw_sc__v2信息

Signed-off-by: HG-ha <60115106+HG-ha@users.noreply.github.com>
Signed-off-by: HG-ha <60115106+HG-ha@users.noreply.github.com>
Signed-off-by: HG-ha <60115106+HG-ha@users.noreply.github.com>
@HG-ha HG-ha changed the title 添加302获取真实链接时的acw_sc__v2验证 添加蓝奏云302获取真实链接时的acw_sc__v2验证 Sep 28, 2025
@jyxjjj jyxjjj requested a review from foxxorcat September 28, 2025 06:13
@jyxjjj
Copy link
Copy Markdown
Member

jyxjjj commented Sep 28, 2025

请修改标题

@HG-ha HG-ha changed the title 添加蓝奏云302获取真实链接时的acw_sc__v2验证 fix(lanzou): support acw_sc__v2 and secondary validation for download link Sep 28, 2025
@HG-ha
Copy link
Copy Markdown
Contributor Author

HG-ha commented Sep 28, 2025

请修改标题

已处理

@HG-ha HG-ha closed this Sep 28, 2025
@HG-ha HG-ha reopened this Sep 28, 2025
foxxorcat
foxxorcat previously approved these changes Sep 28, 2025
Copy link
Copy Markdown
Member

@foxxorcat foxxorcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没啥问题,验证过CalcAcwScV2能用吗,虽然我移植了这个验证,但是一直没有触发过。

@HG-ha
Copy link
Copy Markdown
Contributor Author

HG-ha commented Sep 28, 2025

这是最新acw_sc_v2,已验证可用的python版本

def acw_sc_v2(response):
    arg1 = re.compile(r"arg1='(.*)';").findall(response.text)[0]
    pos_list = [15, 35, 29, 24, 33, 16, 1, 38, 10, 9, 19, 31, 40, 27, 22, 23, 25, 13, 6, 11, 39, 18, 20, 8, 14, 21, 32, 26, 2, 30, 7, 4, 17, 5, 3, 28, 34, 37, 12, 36]
    mask = "3000176000856006061501533003690027800375"

    output_list = [''] * len(pos_list)
    for i in range(len(arg1)):
        char = arg1[i]
        for j in range(len(pos_list)):
            if pos_list[j] == i + 1:
                output_list[j] = char
                break
    
    arg2 = "".join(output_list)

    arg3 = ""
    for i in range(0, min(len(arg2), len(mask)), 2):
        str_char_hex = arg2[i:i+2]
        mask_char_hex = mask[i:i+2]
        
        str_char_int = int(str_char_hex, 16)
        mask_char_int = int(mask_char_hex, 16)
        
        xor_result = str_char_int ^ mask_char_int
        
        xor_char = format(xor_result, '02x')
        arg3 += xor_char
    return arg3

@jyxjjj jyxjjj linked an issue Sep 28, 2025 that may be closed by this pull request
8 tasks
foxxorcat
foxxorcat previously approved these changes Sep 28, 2025
ILoveScratch2
ILoveScratch2 previously approved these changes Sep 28, 2025
Handle error when reading response body.

Signed-off-by: HG-ha <60115106+HG-ha@users.noreply.github.com>
@HG-ha HG-ha dismissed stale reviews from ILoveScratch2 and foxxorcat via 8bdd889 September 28, 2025 10:53
优化重定向资源管理,添加二次人机验证acw_sc__v2处理

Signed-off-by: HG-ha <60115106+HG-ha@users.noreply.github.com>
@HG-ha
Copy link
Copy Markdown
Contributor Author

HG-ha commented Sep 28, 2025

重定向获取真实下载地址、触发二次人机验证时,都需要处理acw_sc__v2,已更新代码

@HG-ha
Copy link
Copy Markdown
Contributor Author

HG-ha commented Sep 28, 2025

本地测试运行良好
image

@HG-ha
Copy link
Copy Markdown
Contributor Author

HG-ha commented Sep 30, 2025

此合并无进展,已推送临时修复分支到docker hub

docker pull yiminger/openlisty:latest

@jyxjjj
Copy link
Copy Markdown
Member

jyxjjj commented Sep 30, 2025

才两天

@jyxjjj jyxjjj merged commit 89759b6 into OpenListTeam:main Sep 30, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 蓝奏云无法正常的下载

5 participants