From ed46646745b7c0dd963cea6ca6f42641a68a0d72 Mon Sep 17 00:00:00 2001 From: yggo <3151543536@qq.com> Date: Tue, 2 Feb 2021 13:33:23 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E7=89=88=E6=9C=AC=202=E3=80=81=E4=BD=BF=E7=94=A8=20C#=208.0=20?= =?UTF-8?q?using=20=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 64 ++++---- Common/Common.cs | 4 +- Component/PacketAnalyzer.cs | 4 +- Component/PacketFormatter.cs | 98 ++++++------- Form/FormMain.cs | 11 +- Form/Tab/TabCapture/CtxMenuAnalysisTools.cs | 12 +- Form/Tab/TabCapture/CtxMenuPackets.cs | 6 +- Form/Tab/TabCapture/TabCapture.cs | 3 +- HttpServer/HttpServerHandler.cs | 2 +- PbParser/PbFormatter.cs | 47 +++--- TLVParser/TLVFormatter.cs | 2 +- Utils/EcdhCrypt.cs | 2 +- Utils/FileUtil.cs | 18 +-- Utils/Util.cs | 32 ++-- YgAndroidQQSniffer.csproj | 142 +++++++++++------- packages.config | 154 ++++++++++---------- 16 files changed, 313 insertions(+), 288 deletions(-) diff --git a/App.config b/App.config index ad1909d..d90a521 100644 --- a/App.config +++ b/App.config @@ -1,65 +1,69 @@ - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + diff --git a/Common/Common.cs b/Common/Common.cs index 2a5546b..cda2f85 100644 --- a/Common/Common.cs +++ b/Common/Common.cs @@ -1,5 +1,4 @@ -using App.Metrics.Concurrency; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using YgAndroidQQSniffer.Extension; @@ -35,7 +34,6 @@ public class DecryptionKey } public class Common { - public static AtomicInteger Index; public static LinkedList Keys { get; set; } = new LinkedList(); diff --git a/Component/PacketAnalyzer.cs b/Component/PacketAnalyzer.cs index 31624e7..c99d899 100644 --- a/Component/PacketAnalyzer.cs +++ b/Component/PacketAnalyzer.cs @@ -86,7 +86,7 @@ protected void Resolve0A01() int qq_len = Buf.ReadInt() - 4; Uin = Buf.ReadCharSequence(qq_len, Encoding.UTF8).ToString(); byte[] remaining = Util.ReadRemainingBytes(Buf); - byte[] decrypt_data = Common.TeaKeyLogDecrypt(remaining, out DecryptionKey decryptionKey); + byte[] decrypt_data = Common.TeaKeyLogDecrypt(remaining, out _); if (decrypt_data == null) return; var buf_part1 = Unpooled.WrappedBuffer(decrypt_data); buf_part1.ReadInt(); @@ -204,7 +204,7 @@ protected void Resolve0B01() int qq_len = Buf.ReadInt() - 4; Uin = Buf.ReadCharSequence(qq_len, Encoding.UTF8).ToString(); byte[] remaining = Util.ReadRemainingBytes(Buf); - byte[] decrypt_data = Common.TeaKeyLogDecrypt(remaining, out DecryptionKey decryptionKey); + byte[] decrypt_data = Common.TeaKeyLogDecrypt(remaining, out _); if (decrypt_data == null) return; var buf_part1 = Unpooled.WrappedBuffer(decrypt_data); buf_part1.ReadInt();//head_size diff --git a/Component/PacketFormatter.cs b/Component/PacketFormatter.cs index 317c792..6aeef66 100644 --- a/Component/PacketFormatter.cs +++ b/Component/PacketFormatter.cs @@ -7,32 +7,32 @@ namespace YgAndroidQQSniffer.Component { public class PacketFormatter : IParser { - private StringBuilder _sb { get; set; } = new StringBuilder(); - private IByteBuffer _buf { get; set; } + private StringBuilder Sb { get; set; } = new StringBuilder(); + private IByteBuffer Buf { get; set; } public string Uin { get; set; } public string Parse(IByteBuffer value) { - _buf = value; + Buf = value; ReadPacketLen(); - int packet_type = _buf.ReadInt(); - byte encrypt_type = _buf.ReadByte(); + int packet_type = Buf.ReadInt(); + byte encrypt_type = Buf.ReadByte(); if (packet_type == 0x0A) { - _sb.Append(packet_type.HexPadLeft().HexDump()).Append(" //packet_type").AppendLine(); + Sb.Append(packet_type.HexPadLeft().HexDump()).Append(" //packet_type").AppendLine(); if (encrypt_type == 0x01) { - _sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); + Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); Resolve0A01(); } else if (encrypt_type == 0x02) { - _sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); + Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); Resolve0A02(); } else if (encrypt_type == 0x00) { - _sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); + Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); Resolve0A00(); } else @@ -42,20 +42,20 @@ public string Parse(IByteBuffer value) } else if (packet_type == 0x0B) { - _sb.Append(packet_type.HexPadLeft().HexDump()).Append(" //packet_type").AppendLine(); + Sb.Append(packet_type.HexPadLeft().HexDump()).Append(" //packet_type").AppendLine(); if (encrypt_type == 0x01) { - _sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); + Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); Resolve0B01(); } else if (encrypt_type == 0x02) { - _sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); + Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); Resolve0B02(); } else if (encrypt_type == 0x00) { - _sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); + Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine(); Resolve0B00(); } else @@ -67,13 +67,13 @@ public string Parse(IByteBuffer value) { throw new InvalidOperationException("invalid packet_type: " + packet_type.HexPadLeft()); } - return _sb.ToString(); + return Sb.ToString(); } private void ReadPacketLen() { - int packet_len = _buf.ReadInt(); - _sb.Append(packet_len.HexPadLeft().HexDump()).Append($" //packet_len {packet_len}").AppendLine(); + int packet_len = Buf.ReadInt(); + Sb.Append(packet_len.HexPadLeft().HexDump()).Append($" //packet_len {packet_len}").AppendLine(); } private void Resolve0A01() @@ -83,92 +83,92 @@ private void Resolve0A01() private void Resolve0A02() { - if (_buf.GetInt(_buf.ReaderIndex) == 0x04) + if (Buf.GetInt(Buf.ReaderIndex) == 0x04) { - _sb.Append(_buf.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(Buf.ReadInt().HexPadLeft().HexDump()).AppendLine(); } - _sb.Append(_buf.ReadByte().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(Buf.ReadByte().HexPadLeft().HexDump()).AppendLine(); - int uin_len = _buf.ReadInt() - 4; - Uin = _buf.ReadCharSequence(uin_len, Encoding.UTF8).ToString(); + int uin_len = Buf.ReadInt() - 4; + Uin = Buf.ReadCharSequence(uin_len, Encoding.UTF8).ToString(); - _sb.Append((uin_len + 4).HexPadLeft().HexDump()).Append(" //uin_len").AppendLine(); - _sb.Append(Encoding.UTF8.GetBytes(Uin).HexDump()).Append($" //uin {Uin}").AppendLine(); + Sb.Append((uin_len + 4).HexPadLeft().HexDump()).Append(" //uin_len").AppendLine(); + Sb.Append(Encoding.UTF8.GetBytes(Uin).HexDump()).Append($" //uin {Uin}").AppendLine(); - byte[] remaining = Util.ReadRemainingBytes(_buf); - _sb.Append(remaining.HexDump()).AppendLine().AppendLine(); + byte[] remaining = Util.ReadRemainingBytes(Buf); + Sb.Append(remaining.HexDump()).AppendLine().AppendLine(); byte[] decrypt_data = Common.TeaKeyLogDecrypt(remaining, out DecryptionKey decryptionKey); if (decrypt_data == null) return; var buf_part1 = Unpooled.WrappedBuffer(decrypt_data); - _sb.Append(Common.PrettyKeyDecryptDump(decrypt_data, decryptionKey)).AppendLine(); + Sb.Append(Common.PrettyKeyDecryptDump(decrypt_data, decryptionKey)).AppendLine(); int head_size = buf_part1.ReadInt(); - _sb.Append(head_size.HexPadLeft().HexDump()).Append($" //head_size {head_size}").AppendLine(); + Sb.Append(head_size.HexPadLeft().HexDump()).Append($" //head_size {head_size}").AppendLine(); uint sso_seq = buf_part1.ReadUnsignedInt(); - _sb.Append(sso_seq.HexPadLeft().HexDump()).Append($" //sso_seq {sso_seq}").AppendLine(); + Sb.Append(sso_seq.HexPadLeft().HexDump()).Append($" //sso_seq {sso_seq}").AppendLine(); if (buf_part1.GetInt(buf_part1.ReaderIndex) == 0x00) { - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); } else { uint appid = buf_part1.ReadUnsignedInt(); - _sb.Append(appid.HexPadLeft().HexDump()).Append($" //appid {appid}").AppendLine(); + Sb.Append(appid.HexPadLeft().HexDump()).Append($" //appid {appid}").AppendLine(); uint appid2 = buf_part1.ReadUnsignedInt(); - _sb.Append(appid2.HexPadLeft().HexDump()).Append($" //appid2 {appid2}").AppendLine(); + Sb.Append(appid2.HexPadLeft().HexDump()).Append($" //appid2 {appid2}").AppendLine(); - _sb.Append(buf_part1.ReadBytes(12).HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadBytes(12).HexDump()).AppendLine(); if (buf_part1.GetInt(buf_part1.ReaderIndex) == 0x4C) { int tgt_len = buf_part1.ReadInt(); - _sb.Append(tgt_len.HexPadLeft().HexDump()).Append($"// tgt_len {tgt_len}").AppendLine(); - _sb.Append(buf_part1.ReadBytes(tgt_len - 4).HexDump()).Append(" //tgt").AppendLine(); + Sb.Append(tgt_len.HexPadLeft().HexDump()).Append($"// tgt_len {tgt_len}").AppendLine(); + Sb.Append(buf_part1.ReadBytes(tgt_len - 4).HexDump()).Append(" //tgt").AppendLine(); } else { - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); } } int service_cmd_len = buf_part1.ReadInt() - 4; string serviceCmd = buf_part1.ReadCharSequence(service_cmd_len, Encoding.UTF8).ToString(); - _sb.Append((service_cmd_len + 4).HexPadLeft().HexDump()).Append($" //service_cmd_len {service_cmd_len}").AppendLine(); - _sb.Append(Encoding.UTF8.GetBytes(serviceCmd).HexDump()).Append($" //serviceCmd [{serviceCmd}]").AppendLine(); + Sb.Append((service_cmd_len + 4).HexPadLeft().HexDump()).Append($" //service_cmd_len {service_cmd_len}").AppendLine(); + Sb.Append(Encoding.UTF8.GetBytes(serviceCmd).HexDump()).Append($" //serviceCmd [{serviceCmd}]").AppendLine(); - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); int imei_len = buf_part1.ReadInt() - 4; string imei = buf_part1.ReadCharSequence(imei_len, Encoding.UTF8).ToString(); - _sb.Append((imei_len + 4).HexPadLeft().HexDump()).Append($" //imei_len {imei_len}").AppendLine(); - _sb.Append(Encoding.UTF8.GetBytes(imei).HexDump()).Append($" //imei [{imei}]").AppendLine(); + Sb.Append((imei_len + 4).HexPadLeft().HexDump()).Append($" //imei_len {imei_len}").AppendLine(); + Sb.Append(Encoding.UTF8.GetBytes(imei).HexDump()).Append($" //imei [{imei}]").AppendLine(); if (buf_part1.GetInt(buf_part1.ReaderIndex) == 0x14) { - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); - _sb.Append(buf_part1.ReadBytes(16).HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadBytes(16).HexDump()).AppendLine(); } else { - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); } short ksid_len = buf_part1.ReadShort(); string ksid = buf_part1.ReadCharSequence(ksid_len - 2, Encoding.UTF8).ToString(); - _sb.Append((ksid_len + 4).HexPadLeft().HexDump()).Append($" //ksid_len {ksid_len}").AppendLine(); - _sb.Append(Encoding.UTF8.GetBytes(ksid).HexDump()).Append($" //ksid [{ksid}]").AppendLine(); + Sb.Append((ksid_len + 4).HexPadLeft().HexDump()).Append($" //ksid_len {ksid_len}").AppendLine(); + Sb.Append(Encoding.UTF8.GetBytes(ksid).HexDump()).Append($" //ksid [{ksid}]").AppendLine(); - _sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); + Sb.Append(buf_part1.ReadInt().HexPadLeft().HexDump()).AppendLine(); uint wupBuffer_len = buf_part1.ReadUnsignedInt(); - _sb.Append((wupBuffer_len + 4).HexPadLeft().HexDump()).Append($" //wupBuffer_len {wupBuffer_len}").AppendLine(); + Sb.Append((wupBuffer_len + 4).HexPadLeft().HexDump()).Append($" //wupBuffer_len {wupBuffer_len}").AppendLine(); - _sb.Append(buf_part1.HexDump()); + Sb.Append(buf_part1.HexDump()); } private void Resolve0A00() diff --git a/Form/FormMain.cs b/Form/FormMain.cs index df21788..16e7757 100644 --- a/Form/FormMain.cs +++ b/Form/FormMain.cs @@ -1,5 +1,4 @@ -using App.Metrics.Concurrency; -using DotNetty.Buffers; +using DotNetty.Buffers; using DotNetty.Common.Utilities; using NLog; using SharpPcap; @@ -53,7 +52,7 @@ private void OptimizeListView() private void RegCustomEvents() { - bool IsCustomEventAttrbute(Attribute[] o) + static bool IsCustomEventAttrbute(Attribute[] o) { foreach (Attribute a in o) { @@ -299,7 +298,6 @@ private void Button_start_capture_Click(object sender, EventArgs e) { if (Device == null || Device.Started) return; lv_packet_log.Items.Clear(); - Common.Index = new AtomicInteger(); Device.Open(DeviceMode.Normal, 1000); Device.Filter = "tcp port 8080 or tcp port 14000 or tcp port 443"; Device.OnPacketArrival += new PacketArrivalEventHandler(Device_OnPacketArrival); @@ -324,7 +322,6 @@ private void Button_stop_capture_Click(object sender, EventArgs e) private void Button_clear_packet_log_Click(object sender, EventArgs e) { lv_packet_log.Items.Clear(); - Common.Index = new AtomicInteger(0); } private string _dstIp { get; set; } private void Device_OnPacketArrival(object sender, CaptureEventArgs e) @@ -376,7 +373,7 @@ private void Device_OnPacketArrival(object sender, CaptureEventArgs e) _dstIp = dstIp.ToString(); lv = new ListViewItem() { - Text = Common.Index.Increment(1).ToString(), + Text = (lv_packet_log.Items.Count + 1).ToString(), SubItems = { orientation, @@ -406,7 +403,7 @@ private void Device_OnPacketArrival(object sender, CaptureEventArgs e) { lv = new ListViewItem() { - Text = Common.Index.Increment(1).ToString(), + Text = (lv_packet_log.Items.Count + 1).ToString(), SubItems = { orientation, diff --git a/Form/Tab/TabCapture/CtxMenuAnalysisTools.cs b/Form/Tab/TabCapture/CtxMenuAnalysisTools.cs index 2e13eba..4168ce4 100644 --- a/Form/Tab/TabCapture/CtxMenuAnalysisTools.cs +++ b/Form/Tab/TabCapture/CtxMenuAnalysisTools.cs @@ -233,13 +233,11 @@ private void Inflater解压ToolStripMenuItem_Click(object sender, EventArgs e) try { - using (MemoryStream compressedStream = new MemoryStream(HexUtil.DecodeHex(selected_text))) - using (DeflateStream deflateStream = new DeflateStream(compressedStream, CompressionMode.Decompress)) - using (MemoryStream outputStream = new MemoryStream()) - { - deflateStream.CopyTo(outputStream); - Frm.Log($"\n\n[{outputStream.ToArray().HexDump()}]\n\n"); - } + using MemoryStream compressedStream = new MemoryStream(HexUtil.DecodeHex(selected_text)); + using DeflateStream deflateStream = new DeflateStream(compressedStream, CompressionMode.Decompress); + using MemoryStream outputStream = new MemoryStream(); + deflateStream.CopyTo(outputStream); + Frm.Log($"\n\n[{outputStream.ToArray().HexDump()}]\n\n"); /*using (var inputStream = new InflaterInputStream(compressedStream)) { inputStream.CopyTo(outputStream); diff --git a/Form/Tab/TabCapture/CtxMenuPackets.cs b/Form/Tab/TabCapture/CtxMenuPackets.cs index e6eaad8..0523a23 100644 --- a/Form/Tab/TabCapture/CtxMenuPackets.cs +++ b/Form/Tab/TabCapture/CtxMenuPackets.cs @@ -1,5 +1,4 @@ -using App.Metrics.Concurrency; -using System; +using System; using System.Collections.Generic; using System.Drawing; using System.IO; @@ -97,7 +96,6 @@ private void SaveCapturePacketsLogs_Click(object sender, EventArgs e) private void DisplayPacketLogListView(string data) { Frm.lv_packet_log.Items.Clear(); - Common.Index = new AtomicInteger(); string[] rows = data.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); List lvs = new List(); @@ -115,7 +113,7 @@ private void DisplayPacketLogListView(string data) string payload = col[6]; lvs.Add(new ListViewItem() { - Text = Common.Index.Increment(1).ToString(), + Text = index, SubItems = { orientation, diff --git a/Form/Tab/TabCapture/TabCapture.cs b/Form/Tab/TabCapture/TabCapture.cs index af6b674..43a5d8f 100644 --- a/Form/Tab/TabCapture/TabCapture.cs +++ b/Form/Tab/TabCapture/TabCapture.cs @@ -1,5 +1,4 @@ -using App.Metrics.Concurrency; -using System; +using System; using System.Collections.Generic; using System.Drawing; using System.IO; diff --git a/HttpServer/HttpServerHandler.cs b/HttpServer/HttpServerHandler.cs index 54e3376..672d689 100644 --- a/HttpServer/HttpServerHandler.cs +++ b/HttpServer/HttpServerHandler.cs @@ -30,7 +30,7 @@ protected override AsciiString GetInitialValue() static readonly AsciiString DateEntity = HttpHeaderNames.Date; static readonly AsciiString ContentLengthEntity = HttpHeaderNames.ContentLength; static readonly AsciiString ServerEntity = HttpHeaderNames.Server; - static BlockingCollection _keys = new BlockingCollection(); + static readonly BlockingCollection _keys = new BlockingCollection(); static readonly string HookMethodName = "methodName"; static readonly string HookMethodValue = "methodValue"; diff --git a/PbParser/PbFormatter.cs b/PbParser/PbFormatter.cs index 2617578..ff14d2f 100644 --- a/PbParser/PbFormatter.cs +++ b/PbParser/PbFormatter.cs @@ -9,35 +9,32 @@ public class PbFormatter : IParser { public string Parse(IByteBuffer value) { - using (Process process = new Process()) - { - process.StartInfo.FileName = "cmd.exe"; - // 是否使用操作系统shell启动 - process.StartInfo.UseShellExecute = false; - // 接收来自调用程序的输入信息 - process.StartInfo.RedirectStandardInput = true; - // 由调用程序获取输出信息 - process.StartInfo.RedirectStandardOutput = true; - // 重定向标准错误输出 - process.StartInfo.RedirectStandardError = true; - // 不显示程序窗口 - process.StartInfo.CreateNoWindow = true; - - process.Start(); + using Process process = new Process(); + process.StartInfo.FileName = "cmd.exe"; + // 是否使用操作系统shell启动 + process.StartInfo.UseShellExecute = false; + // 接收来自调用程序的输入信息 + process.StartInfo.RedirectStandardInput = true; + // 由调用程序获取输出信息 + process.StartInfo.RedirectStandardOutput = true; + // 重定向标准错误输出 + process.StartInfo.RedirectStandardError = true; + // 不显示程序窗口 + process.StartInfo.CreateNoWindow = true; - //process.StandardInput.WriteLine(@"C:\Users\yggo\Desktop\protoc.exe --decode_raw < G:\C#WorkSpace\EpointMsgReverse\bin\Debug\test.bin&exit"); - process.StandardInput.WriteLine(@"C:\Users\yggo\Desktop\protoc.exe --decode_raw < " + WriteTmpBinFile(value) + "&exit"); + process.Start(); - process.StandardInput.AutoFlush = true; - // Synchronously read the standard output of the spawned process. - StreamReader reader = process.StandardOutput; - string output = reader.ReadToEnd(); + //process.StandardInput.WriteLine(@"C:\Users\yggo\Desktop\protoc.exe --decode_raw < G:\C#WorkSpace\EpointMsgReverse\bin\Debug\test.bin&exit"); + process.StandardInput.WriteLine(@"C:\Users\yggo\Desktop\protoc.exe --decode_raw < " + WriteTmpBinFile(value) + "&exit"); - process.WaitForExit(); - // Write the redirected output to this application's window. - return output; + process.StandardInput.AutoFlush = true; + // Synchronously read the standard output of the spawned process. + StreamReader reader = process.StandardOutput; + string output = reader.ReadToEnd(); - } + process.WaitForExit(); + // Write the redirected output to this application's window. + return output; } private string WriteTmpBinFile(IByteBuffer value) diff --git a/TLVParser/TLVFormatter.cs b/TLVParser/TLVFormatter.cs index e7b70c3..f8da487 100644 --- a/TLVParser/TLVFormatter.cs +++ b/TLVParser/TLVFormatter.cs @@ -14,7 +14,7 @@ public class TLVFormatter : IParser public static void RegTLVParsers() { - bool IsTLVParserAttrbute(Attribute[] o) + static bool IsTLVParserAttrbute(Attribute[] o) { foreach (Attribute a in o) { diff --git a/Utils/EcdhCrypt.cs b/Utils/EcdhCrypt.cs index 76bc65c..72d4c3c 100644 --- a/Utils/EcdhCrypt.cs +++ b/Utils/EcdhCrypt.cs @@ -54,7 +54,7 @@ internal static class Libcrypto private byte[] PublicKey = new byte[1024]; private byte[] PrivateKey = new byte[1024]; - private byte[] ShareKey = new byte[16]; + private readonly byte[] ShareKey = new byte[16]; private const string SvrPubKey = "0440eaf325b9c66225143aa7f3961c953c3d5a8048c2b73293cdc7dcbab7f35c4c66aa8917a8fd511f9d969d02c8501bcaa3e3b11746f00567e3aea303ac5f2d25"; public int Publen { get; private set; } public int Prilen { get; private set; } diff --git a/Utils/FileUtil.cs b/Utils/FileUtil.cs index b659451..fd45139 100644 --- a/Utils/FileUtil.cs +++ b/Utils/FileUtil.cs @@ -7,21 +7,17 @@ public class FileUtil { public static string ReadString(string filename) { - using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - byte[] buffer = new byte[fs.Length]; - fs.Read(buffer, 0, (int)fs.Length); - return Encoding.UTF8.GetString(buffer); - } + using FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + byte[] buffer = new byte[fs.Length]; + fs.Read(buffer, 0, (int)fs.Length); + return Encoding.UTF8.GetString(buffer); } public static void WriteString(string filename, string content) { - using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) - { - byte[] buf = Encoding.UTF8.GetBytes(content); - fs.Write(buf, 0, buf.Length); - } + using FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); + byte[] buf = Encoding.UTF8.GetBytes(content); + fs.Write(buf, 0, buf.Length); } } } diff --git a/Utils/Util.cs b/Utils/Util.cs index 3d2e32f..22e4d26 100644 --- a/Utils/Util.cs +++ b/Utils/Util.cs @@ -137,33 +137,27 @@ public static DateTime HexToDateTime(this long timestamp) } public static string Md5(this string input) { - using (MD5 mi = MD5.Create()) + using MD5 mi = MD5.Create(); + byte[] buffer = Encoding.UTF8.GetBytes(input); + byte[] newBuffer = mi.ComputeHash(buffer); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < newBuffer.Length; i++) { - byte[] buffer = Encoding.UTF8.GetBytes(input); - byte[] newBuffer = mi.ComputeHash(buffer); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < newBuffer.Length; i++) - { - sb.Append(newBuffer[i].ToString("x2")); - } - return sb.ToString(); + sb.Append(newBuffer[i].ToString("x2")); } + return sb.ToString(); } public static byte[] Md5(this byte[] input) { - using (MD5 mi = MD5.Create()) - { - return mi.ComputeHash(input); - } + using MD5 mi = MD5.Create(); + return mi.ComputeHash(input); } public static byte[] GenerateMD5Byte(this string input) { - using (MD5 mi = MD5.Create()) - { - byte[] buffer = Encoding.UTF8.GetBytes(input); - byte[] newBuffer = mi.ComputeHash(buffer); - return newBuffer; - } + using MD5 mi = MD5.Create(); + byte[] buffer = Encoding.UTF8.GetBytes(input); + byte[] newBuffer = mi.ComputeHash(buffer); + return newBuffer; } public static Type[] GetExportedTypes(this Type assembly) { diff --git a/YgAndroidQQSniffer.csproj b/YgAndroidQQSniffer.csproj index e4a3680..80d63f0 100644 --- a/YgAndroidQQSniffer.csproj +++ b/YgAndroidQQSniffer.csproj @@ -9,7 +9,7 @@ WinExe YgAndroidQQSniffer YgAndroidQQSniffer - v4.6.1 + v4.7.2 512 true true @@ -57,7 +57,7 @@ DEBUG;TRACE full x64 - 7.3 + 8.0 prompt MixedMinimumRules.ruleset true @@ -68,15 +68,12 @@ true pdbonly x64 - 7.3 + 8.0 prompt MinimumRecommendedRules.ruleset true - - packages\App.Metrics.Concurrency.2.0.2\lib\net45\App.Metrics.Concurrency.dll - packages\Costura.Fody.4.1.0\lib\net40\Costura.dll @@ -101,35 +98,35 @@ packages\Google.Protobuf.3.14.0\lib\net45\Google.Protobuf.dll - - packages\Microsoft.Bcl.AsyncInterfaces.1.1.1\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll - - packages\Microsoft.Extensions.Configuration.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + packages\Microsoft.Extensions.Configuration.5.0.0\lib\net461\Microsoft.Extensions.Configuration.dll - - packages\Microsoft.Extensions.Configuration.Abstractions.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + packages\Microsoft.Extensions.Configuration.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Configuration.Abstractions.dll - - packages\Microsoft.Extensions.Configuration.Binder.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + packages\Microsoft.Extensions.Configuration.Binder.5.0.0\lib\net461\Microsoft.Extensions.Configuration.Binder.dll - - packages\Microsoft.Extensions.DependencyInjection.3.1.4\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + packages\Microsoft.Extensions.DependencyInjection.5.0.1\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.4\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + packages\Microsoft.Extensions.DependencyInjection.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - packages\Microsoft.Extensions.Logging.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + packages\Microsoft.Extensions.Logging.5.0.0\lib\net461\Microsoft.Extensions.Logging.dll - - packages\Microsoft.Extensions.Logging.Abstractions.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + packages\Microsoft.Extensions.Logging.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll - - packages\Microsoft.Extensions.Options.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + packages\Microsoft.Extensions.Options.5.0.0\lib\net461\Microsoft.Extensions.Options.dll - - packages\Microsoft.Extensions.Primitives.3.1.4\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + packages\Microsoft.Extensions.Primitives.5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll @@ -137,28 +134,28 @@ True - packages\NLog.4.7.2\lib\net45\NLog.dll + packages\NLog.4.7.7\lib\net45\NLog.dll - - packages\PacketDotNet.1.0.5\lib\net45\PacketDotNet.dll + + packages\PacketDotNet.1.2.0\lib\net45\PacketDotNet.dll - - packages\SharpPcap.5.1.0\lib\netstandard2.0\SharpPcap.dll + + packages\SharpPcap.5.4.0\lib\netstandard2.0\SharpPcap.dll - - packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll + + packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll True True packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll - - packages\System.Collections.Immutable.1.7.1\lib\net461\System.Collections.Immutable.dll + + packages\System.Collections.Immutable.5.0.0\lib\net461\System.Collections.Immutable.dll - packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll + packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll @@ -169,14 +166,24 @@ True - - packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll + + packages\System.Diagnostics.DiagnosticSource.5.0.1\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + True + True packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll True True + + packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll True @@ -198,6 +205,16 @@ True True + + packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + packages\System.Memory.4.5.4\lib\net461\System.Memory.dll @@ -215,9 +232,28 @@ packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll - - - packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll + True + True + + + packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll + True + True + + + packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll @@ -225,8 +261,8 @@ True - - packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net461\System.Security.Cryptography.Algorithms.dll + + packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll True True @@ -246,10 +282,18 @@ True + + packages\System.Text.RegularExpressions.4.3.1\lib\net463\System.Text.RegularExpressions.dll + True + True + packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + @@ -389,18 +433,18 @@ + + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + - - - - - - \ No newline at end of file diff --git a/packages.config b/packages.config index 8ec99bd..be9d0a1 100644 --- a/packages.config +++ b/packages.config @@ -1,80 +1,80 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file