From 877a2ff495aba20feb8baf3b3825cebd392403b8 Mon Sep 17 00:00:00 2001 From: 1415ddfer <1783488228@qq.com> Date: Mon, 22 Apr 2024 00:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E7=E9=81=93=EF=BC=8C7k?= =?UTF-8?q?=E7=9A=84=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Manager/EngineManager.cs | 92 ++++++++++++++++++++-------------------- Manager/LoginManager.cs | 89 ++++++++++++++++++++++++++++---------- 2 files changed, 113 insertions(+), 68 deletions(-) diff --git a/Manager/EngineManager.cs b/Manager/EngineManager.cs index 52bd12f..c459e8b 100644 --- a/Manager/EngineManager.cs +++ b/Manager/EngineManager.cs @@ -24,11 +24,11 @@ namespace Zerolauncher.Manager MessageBox.Show("正在更新游戏数据,请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning); return true; } - if (UpDateManager.state) - { - UpDateManager.DoUpdate(); - return true; - } + //if (UpDateManager.state) + //{ + // UpDateManager.DoUpdate(); + // return true; + //} var key = AccToKey(account); if (mGame.ContainsKey(key)) { return false; } if (CacheSha.errorCode != 0) { @@ -241,47 +241,47 @@ namespace Zerolauncher.Manager public static Process CheckEngineSafe(string mod) { bool is_first_luancher = EngineManager.CheckEmpy(); - #region 检测代码 - if (mod == StaticHandleA.UpdateMode) - { - if (DataStream.dataStream.ecs.Length > 10) - { - string? now_bit; - using (SHA256 sha256 = SHA256.Create()) - { - using (FileStream fileStream = File.OpenRead(engine_file)) - { - byte[] hashBytes = sha256.ComputeHash(fileStream); - now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); - } - } - if (DataStream.dataStream.ecs != now_bit) - { - Trace.WriteLine("lalalala" + DataStream.dataStream.ecs); - throw new FileReadException("error esu1!"); - } - } - } - else if (!is_check && is_first_luancher) - { - string? now_bit; - using (SHA256 sha256 = SHA256.Create()) - { - using (FileStream fileStream = File.OpenRead(engine_file)) - { - byte[] hashBytes = sha256.ComputeHash(fileStream); - now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); - } - } - if (CacheSha.GetE() != now_bit) - { - Trace.WriteLine("lalalala1"); - throw new FileReadException("error esu0!"); - } - if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); } - is_check = true; - } - #endregion + //#region 检测代码 + //if (mod == StaticHandleA.UpdateMode) + //{ + // if (DataStream.dataStream.ecs.Length > 10) + // { + // string? now_bit; + // using (SHA256 sha256 = SHA256.Create()) + // { + // using (FileStream fileStream = File.OpenRead(engine_file)) + // { + // byte[] hashBytes = sha256.ComputeHash(fileStream); + // now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); + // } + // } + // if (DataStream.dataStream.ecs != now_bit) + // { + // Trace.WriteLine("lalalala" + DataStream.dataStream.ecs); + // throw new FileReadException("error esu1!"); + // } + // } + //} + //else if (!is_check && is_first_luancher) + //{ + // string? now_bit; + // using (SHA256 sha256 = SHA256.Create()) + // { + // using (FileStream fileStream = File.OpenRead(engine_file)) + // { + // byte[] hashBytes = sha256.ComputeHash(fileStream); + // now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); + // } + // } + // if (CacheSha.GetE() != now_bit) + // { + // Trace.WriteLine("lalalala1"); + // throw new FileReadException("error esu0!"); + // } + // if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); } + // is_check = true; + //} + //#endregion var process = new Process { diff --git a/Manager/LoginManager.cs b/Manager/LoginManager.cs index 3960514..76fcb14 100644 --- a/Manager/LoginManager.cs +++ b/Manager/LoginManager.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using Newtonsoft.Json.Linq; +using System.Diagnostics; using System.Net; using System.Net.Http; @@ -48,6 +49,7 @@ namespace Zerolauncher.Manager try { var response = content != null? await client.PostAsync(url, content): await client.GetAsync(url); + game.Send($"{StaticHandleS.HintText} response.StatusCode{response.StatusCode}"); return await response.Content.ReadAsStringAsync(); } catch (Exception ex) @@ -61,31 +63,34 @@ namespace Zerolauncher.Manager public static async Task DoLogin(SingleGame game) { var client = new HttpClient(); - string? need_web = null; + client.DefaultRequestVersion = HttpVersion.Version20; + client.DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrLower; + client.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0"); + string? need_web = null; client.Timeout = TimeSpan.FromSeconds(3); - switch (game.account.providerId) + game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的{game.account.serverId}服"); + switch (game.account.providerId) { case 0: - game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的1服"); need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}"; { var values = new Dictionary - { - { "loginFrom", "uframe" }, - { "postLoginHandler", "default" }, - { "layoutSelfAdapting", "true" }, - { "externalLogin", "qq" }, - { "displayMode", "popup" }, - { "layout", "vertical" }, - { "appId", "www_home" }, - { "mainDivId", "popup_login_div" }, - { "includeFcmInfo", "false" }, - { "userNameLabel", "4399用户名" }, - { "userNameTip", "请输入4399用户名" }, - { "welcomeTip", "欢迎回到4399" }, - { "username", game.account.userName }, - { "password", game.account.userPWD } - }; + { + { "loginFrom", "uframe" }, + { "postLoginHandler", "default" }, + { "layoutSelfAdapting", "true" }, + { "externalLogin", "qq" }, + { "displayMode", "popup" }, + { "layout", "vertical" }, + { "appId", "www_home" }, + { "mainDivId", "popup_login_div" }, + { "includeFcmInfo", "false" }, + { "userNameLabel", "4399用户名" }, + { "userNameTip", "请输入4399用户名" }, + { "welcomeTip", "欢迎回到4399" }, + { "username", game.account.userName }, + { "password", game.account.userPWD } + }; var responseString = await AssetNet(client, game, "http://ptlogin.4399.com/ptlogin/login.do?v=1", new FormUrlEncodedContent(values)); // eventHandles.__errorCallback('密码错误'); if (responseString == null) break; @@ -122,11 +127,51 @@ namespace Zerolauncher.Manager } need_web = null ; break; - default: + case 1: + need_web = $"http://web.7k7k.com/games/togame.php?target=ddt_7&server_id={game.account.serverId}"; + { + var values = new Dictionary + { + { "username", game.account.userName }, + { "password", game.account.userPWD }, + {"auto", "1" }, + {"formtype", "index_log" } + }; + var responseString = await AssetNet(client, game, "https://web.7k7k.com/source/Post.php", new FormUrlEncodedContent(values)); + if (responseString == null) break; + //game.Send($"{StaticHandleS.HintText} {responseString}"); + JObject jsonObj = JObject.Parse(responseString); + game.Send($"{StaticHandleS.HintText} {jsonObj["info"]}"); + if ((int)jsonObj["status"] != 1) break; + if (!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return; + } + { + HttpResponseMessage response; + try + { + response = await client.GetAsync(need_web); + } + catch (Exception ex) + { + game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}"); + break; + } + var responseString = await response.Content.ReadAsStringAsync(); + Trace.WriteLine(responseString); + responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0]; + //Trace.WriteLine(responseString); + game.Send($"{StaticHandleS.GameSa} {responseString}"); + } + break; + case 2: + need_web = $"http://www.wan.com/game/play/id/{game.account.serverId}"; + break; + default: game.Send($"{StaticHandleS.HintText} 错误。未适配的运营商:{game.account.serverId}"); break; } - client.Dispose(); + game.Send($"{StaticHandleS.HintText} need web{need_web}"); + client.Dispose(); if (need_web == null) return; for (int i = 6; i > 0; i--) {