From 704a02578c094d80fd71ae39a532663f63e5ca47 Mon Sep 17 00:00:00 2001 From: ProgramRipper Date: Mon, 9 Feb 2026 19:59:22 +0800 Subject: [PATCH] fix: tons of change --- .../Internal/Packets/Login/WtLogin.cs | 2 +- .../Internal/Packets/Message/Elem.cs | 206 +++++++++++------- .../Configuration/SignerConfiguration.cs | 2 - Lagrange.Milky/Resources/appsettings.jsonc | 5 +- .../Resources/appsettings_schema.json | 6 +- .../CaptchaResolver/OnlineCaptchaResolver.cs | 27 +-- Lagrange.Milky/Utility/JsonUtility.cs | 1 + Lagrange.Milky/Utility/Signer.cs | 36 +-- 8 files changed, 164 insertions(+), 121 deletions(-) diff --git a/Lagrange.Core/Internal/Packets/Login/WtLogin.cs b/Lagrange.Core/Internal/Packets/Login/WtLogin.cs index b56130a4..8ca3c218 100644 --- a/Lagrange.Core/Internal/Packets/Login/WtLogin.cs +++ b/Lagrange.Core/Internal/Packets/Login/WtLogin.cs @@ -173,7 +173,7 @@ public async Task> BuildOicq09Android(string password) tlvs.Tlv001(); tlvs.Tlv106Pwd(password); tlvs.Tlv116(); - tlvs.Tlv100Android((uint)AppInfo.SdkInfo.MainSigMap); + tlvs.Tlv100Android(16724722); tlvs.Tlv107Android(); tlvs.Tlv142(); tlvs.Tlv144Report(false); diff --git a/Lagrange.Core/Internal/Packets/Message/Elem.cs b/Lagrange.Core/Internal/Packets/Message/Elem.cs index a11b3105..633cc340 100644 --- a/Lagrange.Core/Internal/Packets/Message/Elem.cs +++ b/Lagrange.Core/Internal/Packets/Message/Elem.cs @@ -114,107 +114,147 @@ internal partial class TransElem [ProtoPackable] internal partial class CustomFace { - [ProtoMember(1)] public byte[] Guid { get; set; } - - [ProtoMember(2)] public string FilePath { get; set; } - - [ProtoMember(3)] public string Shortcut { get; set; } - - [ProtoMember(4)] public byte[] Buffer { get; set; } - - [ProtoMember(5)] public byte[] Flag { get; set; } - - [ProtoMember(6)] public byte[]? OldData { get; set; } - - [ProtoMember(7)] public uint FileId { get; set; } - - [ProtoMember(8)] public int? ServerIp { get; set; } - - [ProtoMember(9)] public int? ServerPort { get; set; } - - [ProtoMember(10)] public int FileType { get; set; } - - [ProtoMember(11)] public byte[] Signature { get; set; } - - [ProtoMember(12)] public int Useful { get; set; } - - [ProtoMember(13)] public byte[] Md5 { get; set; } - + [ProtoMember(1)] public string FileMd5Hex { get; set; } // MD5 十六进制字符串 + + [ProtoMember(2)] public uint FileSize { get; set; } // 文件大小 + + [ProtoMember(3)] public string DownloadToken { get; set; } // 下载 Token + + [ProtoMember(4)] public byte[] Unknown4 { get; set; } + + [ProtoMember(5)] public uint Unknown5 { get; set; } // 标志位 + + [ProtoMember(6)] public byte[] Unknown6 { get; set; } + + [ProtoMember(7)] public byte[] FileMd5 { get; set; } // MD5 二进制 + + [ProtoMember(8)] public uint Height { get; set; } // 图片高度 + + [ProtoMember(9)] public uint Width { get; set; } // 图片宽度 + + [ProtoMember(10)] public string FileId { get; set; } // 文件 ID + + [ProtoMember(11)] public byte[] Unknown11 { get; set; } + + [ProtoMember(12)] public int Unknown12 { get; set; } + + [ProtoMember(13)] public uint Unknown13 { get; set; } + [ProtoMember(14)] public string ThumbUrl { get; set; } - + [ProtoMember(15)] public string BigUrl { get; set; } - + [ProtoMember(16)] public string OrigUrl { get; set; } - + [ProtoMember(17)] public int BizType { get; set; } - - [ProtoMember(18)] public int RepeatIndex { get; set; } - - [ProtoMember(19)] public int RepeatImage { get; set; } - + + [ProtoMember(18)] public int Unknown18 { get; set; } + + [ProtoMember(19)] public int Unknown19 { get; set; } + [ProtoMember(20)] public int ImageType { get; set; } - - [ProtoMember(21)] public int Index { get; set; } - - [ProtoMember(22)] public int Width { get; set; } - - [ProtoMember(23)] public int Height { get; set; } - - [ProtoMember(24)] public int Source { get; set; } - - [ProtoMember(25)] public uint Size { get; set; } - - [ProtoMember(26)] public int Origin { get; set; } - - [ProtoMember(27)] public int? ThumbWidth { get; set; } - - [ProtoMember(28)] public int? ThumbHeight { get; set; } - - [ProtoMember(29)] public int ShowLen { get; set; } - - [ProtoMember(30)] public int DownloadLen { get; set; } - - [ProtoMember(31)] public string? X400Url { get; set; } - - [ProtoMember(32)] public int X400Width { get; set; } - - [ProtoMember(33)] public int X400Height { get; set; } - - [ProtoMember(34)] public PbReserve1? PbReserve { get; set; } - [ProtoPackable] - public partial class PbReserve1 - { - [ProtoMember(1)] public int SubType { get; set; } + [ProtoMember(21)] public int Unknown21 { get; set; } + + [ProtoMember(22)] public int Unknown22 { get; set; } + + [ProtoMember(23)] public uint Unknown23 { get; set; } // 与 FileId 相同的 ID + + [ProtoMember(24)] public int Unknown24 { get; set; } + + [ProtoMember(25)] public uint Unknown25 { get; set; } + + [ProtoMember(26)] public int Unknown26 { get; set; } + + [ProtoMember(27)] public int Unknown27 { get; set; } + + [ProtoMember(28)] public int Unknown28 { get; set; } + + [ProtoMember(29)] public CustomFacePbReserve? PbReserve { get; set; } // 扩展信息 (含 rkey) + + [ProtoMember(30)] public int Unknown30 { get; set; } + + [ProtoMember(31)] public string Unknown31 { get; set; } + + [ProtoMember(32)] public int Unknown32 { get; set; } + + [ProtoMember(33)] public int Unknown33 { get; set; } + + [ProtoMember(34)] public CustomFaceOldPbReserve? OldPbReserve { get; set; } +} + +[ProtoPackable] +internal partial class CustomFacePbReserve +{ + [ProtoMember(1)] public int Unknown1 { get; set; } + + [ProtoMember(3)] public int Unknown3 { get; set; } + + [ProtoMember(4)] public int Unknown4 { get; set; } - [ProtoMember(3)] public int Field3 { get; set; } + [ProtoMember(9)] public string Unknown9 { get; set; } - [ProtoMember(4)] public int Field4 { get; set; } + [ProtoMember(10)] public int Unknown10 { get; set; } - [ProtoMember(9)] public string Summary { get; set; } + [ProtoMember(12)] public string Unknown12 { get; set; } - [ProtoMember(10)] public int Field10 { get; set; } + [ProtoMember(18)] public string Unknown18 { get; set; } - [ProtoMember(21)] public PbReserve2 Field21 { get; set; } + [ProtoMember(19)] public string Unknown19 { get; set; } - [ProtoMember(31)] public string Field31 { get; set; } - } + [ProtoMember(21)] public CustomFacePbReserveInner? Inner { get; set; } - [ProtoPackable] - public partial class PbReserve2 - { - [ProtoMember(1)] public int Field1 { get; set; } + [ProtoMember(30)] public string Rkey { get; set; } // 下载密钥 +} + +[ProtoPackable] +internal partial class CustomFacePbReserveInner +{ + [ProtoMember(1)] public int Unknown1 { get; set; } + + [ProtoMember(2)] public string Unknown2 { get; set; } + + [ProtoMember(3)] public int Unknown3 { get; set; } + + [ProtoMember(4)] public int Unknown4 { get; set; } + + [ProtoMember(5)] public int Unknown5 { get; set; } + + [ProtoMember(7)] public string Unknown7 { get; set; } +} + +[ProtoPackable] +internal partial class CustomFaceOldPbReserve +{ + [ProtoMember(1)] public int SubType { get; set; } + + [ProtoMember(3)] public int Field3 { get; set; } + + [ProtoMember(4)] public int Field4 { get; set; } + + [ProtoMember(9)] public string Summary { get; set; } + + [ProtoMember(10)] public int Field10 { get; set; } + + [ProtoMember(21)] public CustomFaceOldPbReserve2 Field21 { get; set; } + + [ProtoMember(31)] public string Field31 { get; set; } +} + +[ProtoPackable] +internal partial class CustomFaceOldPbReserve2 +{ + [ProtoMember(1)] public int Field1 { get; set; } - [ProtoMember(2)] public string Field2 { get; set; } + [ProtoMember(2)] public string Field2 { get; set; } - [ProtoMember(3)] public int Field3 { get; set; } + [ProtoMember(3)] public int Field3 { get; set; } - [ProtoMember(4)] public int Field4 { get; set; } + [ProtoMember(4)] public int Field4 { get; set; } - [ProtoMember(5)] public int Field5 { get; set; } + [ProtoMember(5)] public int Field5 { get; set; } - [ProtoMember(7)] public string Md5Str { get; set; } - } + [ProtoMember(7)] public string Md5Str { get; set; } } [ProtoPackable] diff --git a/Lagrange.Milky/Configuration/SignerConfiguration.cs b/Lagrange.Milky/Configuration/SignerConfiguration.cs index 555d57ed..2c2d5854 100644 --- a/Lagrange.Milky/Configuration/SignerConfiguration.cs +++ b/Lagrange.Milky/Configuration/SignerConfiguration.cs @@ -4,8 +4,6 @@ public class SignerConfiguration { public string? Base { get; set; } - public string? Version { get; set; } - public string? Token { get; set; } public string? ProxyUrl { get; set; } diff --git a/Lagrange.Milky/Resources/appsettings.jsonc b/Lagrange.Milky/Resources/appsettings.jsonc index 0eeaa2bb..093e4f72 100644 --- a/Lagrange.Milky/Resources/appsettings.jsonc +++ b/Lagrange.Milky/Resources/appsettings.jsonc @@ -20,9 +20,6 @@ // Signer Base URL "Base": "https://sign.lagrangecore.org/api/sign", - // Signer version - "Version": "30366", - // Signer token // "Token": null @@ -34,7 +31,7 @@ // Account uin // If the Uin is inconsistent with the actual login account, quick login will not be possible "Uin": 0, - + // Account password // Set to null to login via QrCode // "Password": null, diff --git a/Lagrange.Milky/Resources/appsettings_schema.json b/Lagrange.Milky/Resources/appsettings_schema.json index 7dd69720..bd4e909e 100644 --- a/Lagrange.Milky/Resources/appsettings_schema.json +++ b/Lagrange.Milky/Resources/appsettings_schema.json @@ -41,16 +41,12 @@ }, "Signer": { "type": "object", - "required": ["Base", "Version"], + "required": ["Base"], "properties": { "Base": { "type": "string", "description": "Signer Base URL" }, - "Version": { - "type": "string", - "description": "Signer version" - }, "Token": { "type": ["string", "null"], "description": "Signer token" diff --git a/Lagrange.Milky/Utility/CaptchaResolver/OnlineCaptchaResolver.cs b/Lagrange.Milky/Utility/CaptchaResolver/OnlineCaptchaResolver.cs index daf63603..30ca6314 100644 --- a/Lagrange.Milky/Utility/CaptchaResolver/OnlineCaptchaResolver.cs +++ b/Lagrange.Milky/Utility/CaptchaResolver/OnlineCaptchaResolver.cs @@ -28,21 +28,22 @@ public class OnlineCaptchaResolver(ILogger logger, IOptio { token.ThrowIfCancellationRequested(); - string queryUrl = string.Format(QueryUrl, _bot.BotUin); - var response = await _client.GetAsync(queryUrl, token); - if (response.StatusCode == HttpStatusCode.NotFound) - { - _logger.LogCaptchaWaiting(); - continue; - } + // string queryUrl = string.Format(QueryUrl, _bot.BotUin); + // var response = await _client.GetAsync(queryUrl, token); + // if (response.StatusCode == HttpStatusCode.NotFound) + // { + // _logger.LogCaptchaWaiting(); + // continue; + // } - if (!response.IsSuccessStatusCode) - { - throw new Exception($"Unexpected http status code({response.StatusCode})"); - } + // if (!response.IsSuccessStatusCode) + // { + // throw new Exception($"Unexpected http status code({response.StatusCode})"); + // } - string result = await response.Content.ReadAsStringAsync(token); - string? json = JsonNode.Parse(result)?["data"]?.GetValue(); + // string result = await response.Content.ReadAsStringAsync(token); + // string? json = JsonNode.Parse(result)?["data"]?.GetValue(); + var json = await Console.In.ReadLineAsync(token); if (json == null) continue; return (json.Split('|')[0], json.Split('|')[1]); diff --git a/Lagrange.Milky/Utility/JsonUtility.cs b/Lagrange.Milky/Utility/JsonUtility.cs index 96c13d47..80e49536 100644 --- a/Lagrange.Milky/Utility/JsonUtility.cs +++ b/Lagrange.Milky/Utility/JsonUtility.cs @@ -29,6 +29,7 @@ public static partial class JsonUtility [JsonSerializable(typeof(AndroidDebugXwidRequest))] [JsonSerializable(typeof(AndroidSignerResponse))] [JsonSerializable(typeof(AndroidSignerResponse))] + [JsonSerializable(typeof(AndroidSignerResponse))] // === api === [JsonSerializable(typeof(ApiOkResult))] diff --git a/Lagrange.Milky/Utility/Signer.cs b/Lagrange.Milky/Utility/Signer.cs index dcee185c..2da9496c 100644 --- a/Lagrange.Milky/Utility/Signer.cs +++ b/Lagrange.Milky/Utility/Signer.cs @@ -168,7 +168,6 @@ public class Signer : AndroidBotSignProvider, IDisposable private readonly ILogger _logger; private readonly string _base; - private readonly string _version; private readonly string? _token; private readonly HttpClient _client; @@ -181,7 +180,6 @@ public Signer(ILogger logger, IOptions options) var signerConfiguration = options.Value.Signer; _base = signerConfiguration.Base ?? throw new Exception("Core.Signer.Base cannot be null"); - _version = signerConfiguration.Version ?? throw new Exception("Core.Signer.Version connot be null"); _token = signerConfiguration.Token; _client = new HttpClient(new HttpClientHandler { @@ -230,7 +228,7 @@ public override bool IsWhiteListCommand(string cmd) private async Task GetPcSecSign(string cmd, int seq, ReadOnlyMemory body) { var response = await GetSign( - $"{_base}/{_version}", + _base, new PcSecSignRequest(cmd, seq, Convert.ToHexString(body.Span)) ); @@ -252,7 +250,8 @@ private async Task GetAndroidSecSign(long uin, string cmd, int se seq, Convert.ToHexString(body.Span), Convert.ToHexString(Context.Keystore.Guid), - Context.AppInfo.PtVersion + Context.AppInfo.PtVersion, + "V1_AND_SQ_9.2.20_11650_YYB_D" ) ); @@ -275,7 +274,8 @@ public override async Task GetEnergy(long uin, string data) data, Convert.ToHexString(Context.Keystore.Guid), Context.AppInfo.SdkInfo.SdkVersion, - Context.AppInfo.PtVersion + Context.AppInfo.PtVersion, + "V1_AND_SQ_9.2.20_11650_YYB_D" ) ); @@ -298,7 +298,8 @@ public override async Task GetDebugXwid(long uin, string data) uin, data, Convert.ToHexString(Context.Keystore.Guid), - Context.AppInfo.PtVersion + Context.AppInfo.PtVersion, + "V1_AND_SQ_9.2.20_11650_YYB_D" ) ); @@ -340,17 +341,17 @@ public async Task GetAppInfo() using var request = new HttpRequestMessage(); request.Method = HttpMethod.Get; - request.RequestUri = new Uri($"{_base}/{_version}/appinfo_v2"); + request.RequestUri = new Uri($"{_base}/appinfo_v2"); if (!string.IsNullOrWhiteSpace(_token)) request.Headers.Add("X-API-Key", _token); using var response = await _client.SendAsync(request); if (!response.IsSuccessStatusCode) throw new Exception($"Unexpected http status code({response.StatusCode})"); - var result = JsonUtility.Deserialize(await response.Content.ReadAsStreamAsync()); + var result = JsonUtility.Deserialize>(await response.Content.ReadAsStreamAsync()); if (result == null) throw new NullReferenceException("Result is null"); - _info = result; - return result; + _info = result.Data; + return result.Data; } finally { @@ -400,7 +401,7 @@ public class PcSecSignResponseValue(string sign, string token, string extra) public string Extra { get; init; } = extra; } -public class AndroidSecSignRequest(long uin, string cmd, int seq, string buffer, string guid, string version) +public class AndroidSecSignRequest(long uin, string cmd, int seq, string buffer, string guid, string version, string qua) { [JsonPropertyName("uin")] public long Uin { get; } = uin; @@ -419,9 +420,12 @@ public class AndroidSecSignRequest(long uin, string cmd, int seq, string buffer, [JsonPropertyName("version")] public string Version { get; } = version; + + [JsonPropertyName("qua")] + public string Qua { get; } = qua; } -public class AndroidEnergyRequest(long uin, string data, string guid, string ver, string version) +public class AndroidEnergyRequest(long uin, string data, string guid, string ver, string version, string qua) { [JsonPropertyName("uin")] public long Uin { get; } = uin; @@ -437,9 +441,12 @@ public class AndroidEnergyRequest(long uin, string data, string guid, string ver [JsonPropertyName("version")] public string Version { get; } = version; + + [JsonPropertyName("qua")] + public string Qua { get; } = qua; } -public class AndroidDebugXwidRequest(long uin, string data, string guid, string version) +public class AndroidDebugXwidRequest(long uin, string data, string guid, string version, string qua) { [JsonPropertyName("uin")] public long Uin { get; } = uin; @@ -452,6 +459,9 @@ public class AndroidDebugXwidRequest(long uin, string data, string guid, string [JsonPropertyName("version")] public string Version { get; } = version; + + [JsonPropertyName("qua")] + public string Qua { get; } = qua; } public class AndroidSignerResponse(TData data)