::Thunder 12
::Last updated on 2025/06/22
::落尘之木
@echo off
title Thunder 12 Patch

::提升管理员运行
>NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
    ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
    ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
    "%TEMP%\Getadmin.vbs"
    DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL
    Exit /b
)

::主菜单
:menu
cls
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 欢迎
echo.
echo 请选择项目: 
echo.&echo 【1】一键迅雷12去广告
echo.&echo 【2】恢复广告
echo.&echo 【3】关于作者
echo.
set /p user_input=请输入数字后按Enter:
if %user_input% equ 1 goto Remove_AD
if %user_input% equ 2 goto restore
if %user_input% equ 3 goto about
echo.
echo 输入错误, 请重新输入数字.
pause
goto menu

::一级菜单：一键迅雷12去广告
:Remove_AD
::运行路径校验
if not exist "%~dp0Thunder\Program\resources\bin\ThunderKernel.node" (
echo 路径错误！
echo 本脚本应位于与Thunder同目录下运行，请核对！
pause
goto menu
)
::添加屏蔽hosts
taskkill /f /im Thunder.exe >nul 2>nul
echo.
echo 正在添加屏蔽迅雷12广告hosts...
findstr /i "api-shoulei-ssl.xunlei.com" "%windir%\System32\drivers\etc\hosts" >nul 2>nul
if %errorlevel%==1 (
echo 127.0.0.1 api-shoulei-ssl.xunlei.com >>C:\Windows\System32\drivers\etc\hosts
)
findstr /i "conf-m-ssl.xunlei.com" "%windir%\System32\drivers\etc\hosts" >nul 2>nul
if %errorlevel%==1 (
echo 127.0.0.1 conf-m-ssl.xunlei.com >>C:\Windows\System32\drivers\etc\hosts
)
echo 添加完成。
echo 正在刷新DNS缓存...
ipconfig /flushdns >nul 2>nul
echo 刷新完成。

::移除已下载的广告文件
if exist "%~dp0Thunder\profiles\global_remote_config.json" (
echo 正在移除广告文件...
del "%~dp0Thunder\profiles\global_remote_config.json"
echo 移除完成。
)

::允许防火墙入站规则
echo 正在创建防火墙规则...
netsh advfirewall firewall add rule name="Thunder" dir=in action=allow program="%~dp0Thunder\Program\Thunder.exe" >NUL 2>NUL 
netsh advfirewall firewall add rule name="DownloadSDKServer" dir=in action=allow program="%~dp0Thunder\Program\resources\bin\SDK\DownloadSDKServer.exe" >NUL 2>NUL
netsh advfirewall firewall add rule name="Thunder_XMP" dir=in action=allow program="%~dp0Thunder\Program\resources\app\plugins\XmpPlugin\0.9.1.asar.unpacked\bin\aplayer.exe" >NUL 2>NUL 
netsh advfirewall firewall add rule name="ThunderAD_IP1" dir=in action=block remoteip=183.192.205.143 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP1" dir=in action=block remoteip=2409:8c1e:8f91:100:f6f8:c02:90a8:4098 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP1" dir=in action=block remoteip=2409:8c1e:8f91:101:d914:2c6b:2762:3055 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP1" dir=out action=block remoteip=183.192.205.143 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP1" dir=out action=block remoteip=2409:8c1e:8f91:100:f6f8:c02:90a8:4098 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP1" dir=out action=block remoteip=2409:8c1e:8f91:101:d914:2c6b:2762:3055 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP2" dir=in action=block remoteip=117.185.18.29 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP2" dir=in action=block remoteip=2408:4002:1f10::95 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP2" dir=out action=block remoteip=117.185.18.29 >NUL 2>NUL
netsh advfirewall firewall add rule name="ThunderAD_IP2" dir=out action=block remoteip=2408:4002:1f10::95 >NUL 2>NUL
echo 创建完成。
echo 正在创建快捷方式...
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\迅雷.lnk""):b.TargetPath=""%~dp0Thunder\Program\Thunder.exe"":b.WorkingDirectory=""%~dp0Thunder\Program"":b.Save:close")
echo 创建完成。
echo 操作完成，开始享受清爽迅雷12吧！
echo.
pause
goto menu

::一级菜单：恢复广告
:restore
if not exist "%~dp0Thunder\Program\resources\bin\ThunderKernel.node" (
echo 路径错误！
echo 本脚本应位于与Thunder同目录下运行，请核对！
pause
goto menu
)
::移除屏蔽迅雷12广告hosts
taskkill /f /im Thunder.exe >nul 2>nul
echo 正在移除屏蔽迅雷12广告hosts...
findstr /i "api-shoulei-ssl.xunlei.com" "%windir%\System32\drivers\etc\hosts" >nul 2>nul
if %errorlevel%==0 (
pushd "%windir%\System32\drivers\etc"
find /v "127.0.0.1 api-shoulei-ssl.xunlei.com" <hosts >hosts.new
del hosts>nul
move hosts.new hosts>nul
popd
)
findstr /i "conf-m-ssl.xunlei.com" "%windir%\System32\drivers\etc\hosts" >nul 2>nul
if %errorlevel%==0 (
pushd "%windir%\System32\drivers\etc"
find /v "127.0.0.1 conf-m-ssl.xunlei.com" <hosts >hosts.new
del hosts>nul
move hosts.new hosts>nul
popd
echo 移除完成。
)

::刷新DNS缓存
echo 正在刷新DNS缓存...
ipconfig /flushdns >nul 2>nul
echo 刷新完成。

::删除防火墙入站规则
echo 正在移除防火墙规则...
netsh advfirewall firewall delete rule name="Thunder" >NUL 2>NUL 
netsh advfirewall firewall delete rule name="DownloadSDKServer" >NUL 2>NUL
netsh advfirewall firewall delete rule name="Thunder_XMP" >NUL 2>NUL 
netsh advfirewall firewall delete rule name="ThunderAD_IP1" >NUL 2>NUL
netsh advfirewall firewall delete rule name="ThunderAD_IP2" >NUL 2>NUL
echo 移除完成。
echo.
pause
goto menu


::一级菜单：关于
:about
echo.
echo 制作：落尘之木 分享：下载集xzji.com
pause
goto menu
::Thunder 12
::Last updated on 2025/06/22
::落尘之木