From 217c6974dbc4398e031964edcd3ea3eebdf690e3 Mon Sep 17 00:00:00 2001 From: XAS-712 Date: Mon, 21 Jan 2019 23:41:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96S50=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=8E=92=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MifareOneTool/ClassMifareS50.cs | 37 +++++++++ MifareOneTool/Form1.Designer.cs | 70 ++++++++-------- MifareOneTool/Form1.resx | 3 - MifareOneTool/FormDiff.Designer.cs | 58 ++++++++++++++ MifareOneTool/FormDiff.cs | 19 +++++ MifareOneTool/FormDiff.resx | 120 ++++++++++++++++++++++++++++ MifareOneTool/FormHTool.Designer.cs | 73 ++++++++++------- MifareOneTool/FormHTool.cs | 21 +++++ MifareOneTool/FormHTool.resx | 3 - MifareOneTool/MifareOneTool.csproj | 9 +++ 10 files changed, 341 insertions(+), 72 deletions(-) create mode 100644 MifareOneTool/FormDiff.Designer.cs create mode 100644 MifareOneTool/FormDiff.cs create mode 100644 MifareOneTool/FormDiff.resx diff --git a/MifareOneTool/ClassMifareS50.cs b/MifareOneTool/ClassMifareS50.cs index e959078..2d844a6 100644 --- a/MifareOneTool/ClassMifareS50.cs +++ b/MifareOneTool/ClassMifareS50.cs @@ -227,6 +227,21 @@ namespace MifareOneTool } return info; } + public byte[] KeyA + { + get { return this._sector[3].Skip(0).Take(6).ToArray(); } + set { for (int i = 0; i < 6; i++) { this._sector[3][i] = value[i]; } } + } + public byte[] KeyB + { + get { return this._sector[3].Skip(10).Take(6).ToArray(); } + set { for (int i = 10; i < 16; i++) { this._sector[3][i] = value[i]; } } + } + public byte[] ACBits + { + get { return this._sector[3].Skip(6).Take(4).ToArray(); } + set { for (int i = 6; i < 10; i++) { this._sector[3][i] = value[i]; } } + } } class S50 { @@ -337,5 +352,27 @@ namespace MifareOneTool } File.WriteAllText(file, sb.ToString()); } + public List KeyList() + { + List keys = new List(); + foreach (Sector s in this._sectors) + { + keys.Add(s.KeyA); + keys.Add(s.KeyB); + } + keys = keys.Distinct().ToList(); + return keys; + } + public List KeyListStr() + { + List keys = new List(); + foreach (Sector s in this._sectors) + { + keys.Add(Utils.Hex2Str(s.KeyA)); + keys.Add(Utils.Hex2Str(s.KeyB)); + } + keys = keys.Distinct().ToList(); + return keys; + } } } diff --git a/MifareOneTool/Form1.Designer.cs b/MifareOneTool/Form1.Designer.cs index f3ca0de..bb6187f 100644 --- a/MifareOneTool/Form1.Designer.cs +++ b/MifareOneTool/Form1.Designer.cs @@ -51,9 +51,10 @@ this.buttonConClr = new System.Windows.Forms.Button(); this.buttonMfcuk = new System.Windows.Forms.Button(); this.buttonHexTool = new System.Windows.Forms.Button(); - this.buttonTool1 = new System.Windows.Forms.Button(); + this.buttonDiffTool = new System.Windows.Forms.Button(); this.toolTipHelp = new System.Windows.Forms.ToolTip(this.components); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.buttonCheckEncrypt = new System.Windows.Forms.Button(); this.buttonEnAcr122u = new System.Windows.Forms.Button(); this.buttonMfFormat = new System.Windows.Forms.Button(); this.buttonLockUfuid = new System.Windows.Forms.Button(); @@ -67,6 +68,7 @@ this.button4 = new System.Windows.Forms.Button(); this.buttonEMfWrite = new System.Windows.Forms.Button(); this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.buttonECheckEncrypt = new System.Windows.Forms.Button(); this.buttonEUpdate = new System.Windows.Forms.Button(); this.buttoEScanCard = new System.Windows.Forms.Button(); this.buttonEscan = new System.Windows.Forms.Button(); @@ -82,8 +84,6 @@ this.localVersionLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.remoteVersionLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.timer1 = new System.Windows.Forms.Timer(this.components); - this.buttonCheckEncrypt = new System.Windows.Forms.Button(); - this.buttonECheckEncrypt = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -346,20 +346,20 @@ this.buttonHexTool.Name = "buttonHexTool"; this.buttonHexTool.Size = new System.Drawing.Size(110, 23); this.buttonHexTool.TabIndex = 1; - this.buttonHexTool.Text = "Hex工具"; + this.buttonHexTool.Text = "Hex编辑器"; this.buttonHexTool.UseVisualStyleBackColor = true; this.buttonHexTool.Click += new System.EventHandler(this.buttonHexTool_Click); // - // buttonTool1 + // buttonDiffTool // - this.buttonTool1.Enabled = false; - this.buttonTool1.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonTool1.Location = new System.Drawing.Point(6, 24); - this.buttonTool1.Name = "buttonTool1"; - this.buttonTool1.Size = new System.Drawing.Size(110, 23); - this.buttonTool1.TabIndex = 0; - this.buttonTool1.Text = "key.mfd工具"; - this.buttonTool1.UseVisualStyleBackColor = true; + this.buttonDiffTool.Enabled = false; + this.buttonDiffTool.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonDiffTool.Location = new System.Drawing.Point(6, 24); + this.buttonDiffTool.Name = "buttonDiffTool"; + this.buttonDiffTool.Size = new System.Drawing.Size(110, 23); + this.buttonDiffTool.TabIndex = 0; + this.buttonDiffTool.Text = "差异比较"; + this.buttonDiffTool.UseVisualStyleBackColor = true; // // toolTipHelp // @@ -377,7 +377,7 @@ this.groupBox4.Controls.Add(this.buttonLockUfuid); this.groupBox4.Controls.Add(this.buttonCmfWrite); this.groupBox4.Controls.Add(this.buttonMfcuk); - this.groupBox4.Controls.Add(this.buttonTool1); + this.groupBox4.Controls.Add(this.buttonDiffTool); this.groupBox4.Controls.Add(this.buttonHexTool); this.groupBox4.Location = new System.Drawing.Point(3, 95); this.groupBox4.Name = "groupBox4"; @@ -386,6 +386,16 @@ this.groupBox4.TabStop = false; this.groupBox4.Text = "工具"; // + // buttonCheckEncrypt + // + this.buttonCheckEncrypt.Location = new System.Drawing.Point(360, 23); + this.buttonCheckEncrypt.Name = "buttonCheckEncrypt"; + this.buttonCheckEncrypt.Size = new System.Drawing.Size(75, 23); + this.buttonCheckEncrypt.TabIndex = 13; + this.buttonCheckEncrypt.Text = "检加密"; + this.buttonCheckEncrypt.UseVisualStyleBackColor = true; + this.buttonCheckEncrypt.Click += new System.EventHandler(this.buttonCheckEncrypt_Click); + // // buttonEnAcr122u // this.buttonEnAcr122u.Location = new System.Drawing.Point(279, 52); @@ -525,6 +535,16 @@ this.groupBox6.TabStop = false; this.groupBox6.Text = "[1]检测"; // + // buttonECheckEncrypt + // + this.buttonECheckEncrypt.Location = new System.Drawing.Point(6, 87); + this.buttonECheckEncrypt.Name = "buttonECheckEncrypt"; + this.buttonECheckEncrypt.Size = new System.Drawing.Size(116, 25); + this.buttonECheckEncrypt.TabIndex = 5; + this.buttonECheckEncrypt.Text = "[3]检测加密"; + this.buttonECheckEncrypt.UseVisualStyleBackColor = true; + this.buttonECheckEncrypt.Click += new System.EventHandler(this.buttonECheckEncrypt_Click); + // // buttonEUpdate // this.buttonEUpdate.Location = new System.Drawing.Point(6, 140); @@ -667,26 +687,6 @@ this.timer1.Enabled = true; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // buttonCheckEncrypt - // - this.buttonCheckEncrypt.Location = new System.Drawing.Point(360, 23); - this.buttonCheckEncrypt.Name = "buttonCheckEncrypt"; - this.buttonCheckEncrypt.Size = new System.Drawing.Size(75, 23); - this.buttonCheckEncrypt.TabIndex = 13; - this.buttonCheckEncrypt.Text = "检加密"; - this.buttonCheckEncrypt.UseVisualStyleBackColor = true; - this.buttonCheckEncrypt.Click += new System.EventHandler(this.buttonCheckEncrypt_Click); - // - // buttonECheckEncrypt - // - this.buttonECheckEncrypt.Location = new System.Drawing.Point(6, 87); - this.buttonECheckEncrypt.Name = "buttonECheckEncrypt"; - this.buttonECheckEncrypt.Size = new System.Drawing.Size(116, 25); - this.buttonECheckEncrypt.TabIndex = 5; - this.buttonECheckEncrypt.Text = "[3]检测加密"; - this.buttonECheckEncrypt.UseVisualStyleBackColor = true; - this.buttonECheckEncrypt.Click += new System.EventHandler(this.buttonECheckEncrypt_Click); - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); @@ -740,7 +740,7 @@ private System.Windows.Forms.Button buttonConClr; private System.Windows.Forms.Button buttonKill; private System.Windows.Forms.LinkLabel linkLabel1; - private System.Windows.Forms.Button buttonTool1; + private System.Windows.Forms.Button buttonDiffTool; private System.Windows.Forms.Button buttonHexTool; private System.Windows.Forms.Button buttonMfcuk; private System.Windows.Forms.ToolTip toolTipHelp; diff --git a/MifareOneTool/Form1.resx b/MifareOneTool/Form1.resx index 9f65069..e3a46f8 100644 --- a/MifareOneTool/Form1.resx +++ b/MifareOneTool/Form1.resx @@ -120,9 +120,6 @@ 17, 17 - - 17, 17 - 157, 17 diff --git a/MifareOneTool/FormDiff.Designer.cs b/MifareOneTool/FormDiff.Designer.cs new file mode 100644 index 0000000..2a122e5 --- /dev/null +++ b/MifareOneTool/FormDiff.Designer.cs @@ -0,0 +1,58 @@ +namespace MifareOneTool +{ + partial class FormDiff + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.SuspendLayout(); + // + // richTextBox1 + // + this.richTextBox1.Location = new System.Drawing.Point(12, 43); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(421, 505); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = "A: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11"; + // + // FormDiff + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(445, 560); + this.Controls.Add(this.richTextBox1); + this.Name = "FormDiff"; + this.Text = "FormDiff"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.RichTextBox richTextBox1; + } +} \ No newline at end of file diff --git a/MifareOneTool/FormDiff.cs b/MifareOneTool/FormDiff.cs new file mode 100644 index 0000000..19d0be6 --- /dev/null +++ b/MifareOneTool/FormDiff.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace MifareOneTool +{ + public partial class FormDiff : Form + { + public FormDiff() + { + InitializeComponent(); + } + } +} diff --git a/MifareOneTool/FormDiff.resx b/MifareOneTool/FormDiff.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/MifareOneTool/FormDiff.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MifareOneTool/FormHTool.Designer.cs b/MifareOneTool/FormHTool.Designer.cs index 1db0996..a781950 100644 --- a/MifareOneTool/FormHTool.Designer.cs +++ b/MifareOneTool/FormHTool.Designer.cs @@ -39,7 +39,11 @@ this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.修改UIDToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.检查全卡ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.检查并纠正全卡ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.导出为MCT格式ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -67,10 +71,7 @@ this.groupBox3 = new System.Windows.Forms.GroupBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.s50BindingSource = new System.Windows.Forms.BindingSource(this.components); - this.检查并纠正全卡ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.导出为MCT格式ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.导出密钥字典ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); @@ -157,7 +158,8 @@ this.检查全卡ToolStripMenuItem, this.检查并纠正全卡ToolStripMenuItem, this.toolStripSeparator3, - this.导出为MCT格式ToolStripMenuItem}); + this.导出为MCT格式ToolStripMenuItem, + this.导出密钥字典ToolStripMenuItem}); this.工具ToolStripMenuItem.Name = "工具ToolStripMenuItem"; this.工具ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.工具ToolStripMenuItem.Text = "工具"; @@ -166,18 +168,44 @@ // this.修改UIDToolStripMenuItem.Name = "修改UIDToolStripMenuItem"; this.修改UIDToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U))); - this.修改UIDToolStripMenuItem.Size = new System.Drawing.Size(239, 24); + this.修改UIDToolStripMenuItem.Size = new System.Drawing.Size(248, 24); this.修改UIDToolStripMenuItem.Text = "修改UID"; this.修改UIDToolStripMenuItem.Click += new System.EventHandler(this.修改UIDToolStripMenuItem_Click); // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(245, 6); + // // 检查全卡ToolStripMenuItem // this.检查全卡ToolStripMenuItem.Name = "检查全卡ToolStripMenuItem"; this.检查全卡ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.J))); - this.检查全卡ToolStripMenuItem.Size = new System.Drawing.Size(239, 24); + this.检查全卡ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); this.检查全卡ToolStripMenuItem.Text = "检查全卡"; this.检查全卡ToolStripMenuItem.Click += new System.EventHandler(this.检查全卡ToolStripMenuItem_Click); // + // 检查并纠正全卡ToolStripMenuItem + // + this.检查并纠正全卡ToolStripMenuItem.Name = "检查并纠正全卡ToolStripMenuItem"; + this.检查并纠正全卡ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.K))); + this.检查并纠正全卡ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); + this.检查并纠正全卡ToolStripMenuItem.Text = "检查并纠正全卡"; + this.检查并纠正全卡ToolStripMenuItem.Click += new System.EventHandler(this.检查并纠正全卡ToolStripMenuItem_Click); + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(245, 6); + // + // 导出为MCT格式ToolStripMenuItem + // + this.导出为MCT格式ToolStripMenuItem.Name = "导出为MCT格式ToolStripMenuItem"; + this.导出为MCT格式ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.M))); + this.导出为MCT格式ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); + this.导出为MCT格式ToolStripMenuItem.Text = "导出为MCT格式"; + this.导出为MCT格式ToolStripMenuItem.Click += new System.EventHandler(this.导出为MCT格式ToolStripMenuItem_Click); + // // groupBox1 // this.groupBox1.Controls.Add(this.dataGridView1); @@ -492,31 +520,13 @@ // this.s50BindingSource.DataSource = typeof(MifareOneTool.S50); // - // 检查并纠正全卡ToolStripMenuItem + // 导出密钥字典ToolStripMenuItem // - this.检查并纠正全卡ToolStripMenuItem.Name = "检查并纠正全卡ToolStripMenuItem"; - this.检查并纠正全卡ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.K))); - this.检查并纠正全卡ToolStripMenuItem.Size = new System.Drawing.Size(239, 24); - this.检查并纠正全卡ToolStripMenuItem.Text = "检查并纠正全卡"; - this.检查并纠正全卡ToolStripMenuItem.Click += new System.EventHandler(this.检查并纠正全卡ToolStripMenuItem_Click); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(245, 6); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(245, 6); - // - // 导出为MCT格式ToolStripMenuItem - // - this.导出为MCT格式ToolStripMenuItem.Name = "导出为MCT格式ToolStripMenuItem"; - this.导出为MCT格式ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.M))); - this.导出为MCT格式ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); - this.导出为MCT格式ToolStripMenuItem.Text = "导出为MCT格式"; - this.导出为MCT格式ToolStripMenuItem.Click += new System.EventHandler(this.导出为MCT格式ToolStripMenuItem_Click); + this.导出密钥字典ToolStripMenuItem.Name = "导出密钥字典ToolStripMenuItem"; + this.导出密钥字典ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); + this.导出密钥字典ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); + this.导出密钥字典ToolStripMenuItem.Text = "导出密钥字典"; + this.导出密钥字典ToolStripMenuItem.Click += new System.EventHandler(this.导出密钥字典ToolStripMenuItem_Click); // // FormHTool // @@ -590,5 +600,6 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem 导出为MCT格式ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem 导出密钥字典ToolStripMenuItem; } } \ No newline at end of file diff --git a/MifareOneTool/FormHTool.cs b/MifareOneTool/FormHTool.cs index 3a1a23e..093b514 100644 --- a/MifareOneTool/FormHTool.cs +++ b/MifareOneTool/FormHTool.cs @@ -426,5 +426,26 @@ namespace MifareOneTool } logAppend("已导出MCT文件" + filename + "。"); } + + private void 导出密钥字典ToolStripMenuItem_Click(object sender, EventArgs e) + { + string filename; + SaveFileDialog ofd = new SaveFileDialog(); + ofd.AddExtension = true; + ofd.DefaultExt = ".dic"; + ofd.Title = "请选择密钥字典文件保存位置及文件名"; + ofd.OverwritePrompt = true; + ofd.Filter = "字典文件|*.dic"; + if (ofd.ShowDialog() == DialogResult.OK) + { + filename = ofd.FileName; + } + else + { + return; + } + File.WriteAllLines(filename, this.currentS50.KeyListStr().ToArray()); + logAppend("已导出密钥字典文件" + filename + "。"); + } } } diff --git a/MifareOneTool/FormHTool.resx b/MifareOneTool/FormHTool.resx index 279a098..b3bd9fb 100644 --- a/MifareOneTool/FormHTool.resx +++ b/MifareOneTool/FormHTool.resx @@ -123,9 +123,6 @@ True - - True - 155, 17 diff --git a/MifareOneTool/MifareOneTool.csproj b/MifareOneTool/MifareOneTool.csproj index a576e5e..6494404 100644 --- a/MifareOneTool/MifareOneTool.csproj +++ b/MifareOneTool/MifareOneTool.csproj @@ -73,6 +73,12 @@ Form1.cs + + Form + + + FormDiff.cs + Form @@ -91,6 +97,9 @@ Form1.cs + + FormDiff.cs + FormHTool.cs From 91d2bdb68ad08b15f58a0dae382dfe219eb2721f Mon Sep 17 00:00:00 2001 From: XAS-712 Date: Tue, 22 Jan 2019 03:47:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?v1.6=E5=8A=9F=E8=83=BD=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MifareOneTool/ClassMifareS50.cs | 10 + MifareOneTool/Form1.Designer.cs | 408 ++++++++++++++--------- MifareOneTool/Form1.cs | 264 ++++++++++----- MifareOneTool/Form1.resx | 19 ++ MifareOneTool/FormDiff.Designer.cs | 59 +++- MifareOneTool/FormDiff.cs | 111 ++++++ MifareOneTool/FormHTool.Designer.cs | 31 +- MifareOneTool/FormHTool.cs | 15 + MifareOneTool/GitHubUpdate.cs | 35 +- MifareOneTool/MifareOneTool.csproj | 1 + MifareOneTool/Properties/AssemblyInfo.cs | 4 +- 11 files changed, 700 insertions(+), 257 deletions(-) diff --git a/MifareOneTool/ClassMifareS50.cs b/MifareOneTool/ClassMifareS50.cs index 2d844a6..e6da929 100644 --- a/MifareOneTool/ClassMifareS50.cs +++ b/MifareOneTool/ClassMifareS50.cs @@ -18,6 +18,16 @@ namespace MifareOneTool } return ret.ToString(); } + public static string Hex2StrS(byte[] bytes) + { + StringBuilder ret = new StringBuilder(); + foreach (byte b in bytes) + { + ret.AppendFormat("{0:x2}", b); + ret.Append(" "); + } + return ret.ToString(); + } public static byte[] ReadAC(byte[] ac) { byte[] acbits = new byte[4]; diff --git a/MifareOneTool/Form1.Designer.cs b/MifareOneTool/Form1.Designer.cs index bb6187f..40f4b8a 100644 --- a/MifareOneTool/Form1.Designer.cs +++ b/MifareOneTool/Form1.Designer.cs @@ -29,22 +29,24 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.buttonCLI = new System.Windows.Forms.Button(); + this.buttonEnAcr122u = new System.Windows.Forms.Button(); this.buttonScanCard = new System.Windows.Forms.Button(); this.buttonListDev = new System.Windows.Forms.Button(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.buttonMfRead = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.buttonMfFormat = new System.Windows.Forms.Button(); + this.buttonMfWrite = new System.Windows.Forms.Button(); + this.buttonSelectKey = new System.Windows.Forms.Button(); this.buttonBmfWrite = new System.Windows.Forms.Button(); this.buttonBmfRead = new System.Windows.Forms.Button(); this.buttonMfoc = new System.Windows.Forms.Button(); this.buttonUidWrite = new System.Windows.Forms.Button(); this.buttonUidFormat = new System.Windows.Forms.Button(); this.buttonUidReset = new System.Windows.Forms.Button(); - this.buttonMfWrite = new System.Windows.Forms.Button(); - this.buttonSelectKey = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.buttonKill = new System.Windows.Forms.Button(); this.buttonConSave = new System.Windows.Forms.Button(); @@ -55,8 +57,6 @@ this.toolTipHelp = new System.Windows.Forms.ToolTip(this.components); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.buttonCheckEncrypt = new System.Windows.Forms.Button(); - this.buttonEnAcr122u = new System.Windows.Forms.Button(); - this.buttonMfFormat = new System.Windows.Forms.Button(); this.buttonLockUfuid = new System.Windows.Forms.Button(); this.buttonCmfWrite = new System.Windows.Forms.Button(); this.tabControl1 = new System.Windows.Forms.TabControl(); @@ -78,12 +78,20 @@ this.buttonEMfRead = new System.Windows.Forms.Button(); this.buttonEMfoc = new System.Windows.Forms.Button(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.groupBox10 = new System.Windows.Forms.GroupBox(); + this.buttonHardNested = new System.Windows.Forms.Button(); + this.groupBox9 = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBox8 = new System.Windows.Forms.GroupBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.runTimeLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.localVersionLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.remoteVersionLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolStripCheckUpdate = new System.Windows.Forms.ToolStripSplitButton(); this.timer1 = new System.Windows.Forms.Timer(this.components); + this.buttonnKeysMfoc = new System.Windows.Forms.Button(); + this.buttonDictMfoc = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -94,13 +102,16 @@ this.groupBox6.SuspendLayout(); this.groupBox5.SuspendLayout(); this.tabPage1.SuspendLayout(); + this.groupBox10.SuspendLayout(); + this.groupBox9.SuspendLayout(); + this.groupBox8.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // - this.groupBox1.Controls.Add(this.linkLabel1); this.groupBox1.Controls.Add(this.buttonCLI); + this.groupBox1.Controls.Add(this.buttonEnAcr122u); this.groupBox1.Controls.Add(this.buttonScanCard); this.groupBox1.Controls.Add(this.buttonListDev); this.groupBox1.Location = new System.Drawing.Point(3, 6); @@ -110,17 +121,6 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "设备控制"; // - // linkLabel1 - // - this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(112, 57); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(67, 15); - this.linkLabel1.TabIndex = 6; - this.linkLabel1.TabStop = true; - this.linkLabel1.Text = "检查更新"; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); - // // buttonCLI // this.buttonCLI.Font = new System.Drawing.Font("宋体", 8.5F); @@ -132,10 +132,21 @@ this.buttonCLI.UseVisualStyleBackColor = true; this.buttonCLI.Click += new System.EventHandler(this.buttonCLI_Click); // + // buttonEnAcr122u + // + this.buttonEnAcr122u.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonEnAcr122u.Location = new System.Drawing.Point(102, 53); + this.buttonEnAcr122u.Name = "buttonEnAcr122u"; + this.buttonEnAcr122u.Size = new System.Drawing.Size(90, 23); + this.buttonEnAcr122u.TabIndex = 7; + this.buttonEnAcr122u.Text = "122U支持"; + this.buttonEnAcr122u.UseVisualStyleBackColor = true; + this.buttonEnAcr122u.Click += new System.EventHandler(this.buttonEnAcr122u_Click); + // // buttonScanCard // this.buttonScanCard.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonScanCard.Location = new System.Drawing.Point(6, 53); + this.buttonScanCard.Location = new System.Drawing.Point(4, 53); this.buttonScanCard.Name = "buttonScanCard"; this.buttonScanCard.Size = new System.Drawing.Size(90, 23); this.buttonScanCard.TabIndex = 1; @@ -146,11 +157,11 @@ // buttonListDev // this.buttonListDev.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonListDev.Location = new System.Drawing.Point(6, 24); + this.buttonListDev.Location = new System.Drawing.Point(4, 24); this.buttonListDev.Name = "buttonListDev"; this.buttonListDev.Size = new System.Drawing.Size(90, 23); this.buttonListDev.TabIndex = 0; - this.buttonListDev.Text = "检测"; + this.buttonListDev.Text = "检测设备"; this.buttonListDev.UseVisualStyleBackColor = true; this.buttonListDev.Click += new System.EventHandler(this.buttonListDev_Click); // @@ -158,10 +169,10 @@ // this.richTextBox1.BackColor = System.Drawing.Color.Black; this.richTextBox1.ForeColor = System.Drawing.Color.Lime; - this.richTextBox1.Location = new System.Drawing.Point(12, 219); + this.richTextBox1.Location = new System.Drawing.Point(0, 219); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.ReadOnly = true; - this.richTextBox1.Size = new System.Drawing.Size(623, 300); + this.richTextBox1.Size = new System.Drawing.Size(767, 300); this.richTextBox1.TabIndex = 1; this.richTextBox1.Text = "Hello,cardman!\n建议点击\"检测\"以加快后续运行速度\n"; // @@ -170,105 +181,44 @@ this.buttonMfRead.Font = new System.Drawing.Font("宋体", 8.5F); this.buttonMfRead.Location = new System.Drawing.Point(6, 24); this.buttonMfRead.Name = "buttonMfRead"; - this.buttonMfRead.Size = new System.Drawing.Size(75, 23); + this.buttonMfRead.Size = new System.Drawing.Size(50, 23); this.buttonMfRead.TabIndex = 3; - this.buttonMfRead.Text = "读M1卡"; + this.buttonMfRead.Text = "读M1"; this.buttonMfRead.UseVisualStyleBackColor = true; this.buttonMfRead.Click += new System.EventHandler(this.buttonMfRead_Click); // // groupBox2 // - this.groupBox2.Controls.Add(this.buttonBmfWrite); - this.groupBox2.Controls.Add(this.buttonBmfRead); - this.groupBox2.Controls.Add(this.buttonMfoc); - this.groupBox2.Controls.Add(this.buttonUidWrite); - this.groupBox2.Controls.Add(this.buttonUidFormat); - this.groupBox2.Controls.Add(this.buttonUidReset); + this.groupBox2.Controls.Add(this.buttonMfFormat); this.groupBox2.Controls.Add(this.buttonMfWrite); this.groupBox2.Controls.Add(this.buttonSelectKey); this.groupBox2.Controls.Add(this.buttonMfRead); this.groupBox2.Location = new System.Drawing.Point(209, 6); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(417, 83); + this.groupBox2.Size = new System.Drawing.Size(169, 83); this.groupBox2.TabIndex = 4; this.groupBox2.TabStop = false; - this.groupBox2.Text = "功能"; + this.groupBox2.Text = "普通卡操作"; // - // buttonBmfWrite + // buttonMfFormat // - this.buttonBmfWrite.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonBmfWrite.Location = new System.Drawing.Point(330, 53); - this.buttonBmfWrite.Name = "buttonBmfWrite"; - this.buttonBmfWrite.Size = new System.Drawing.Size(75, 23); - this.buttonBmfWrite.TabIndex = 10; - this.buttonBmfWrite.Text = "UID写"; - this.buttonBmfWrite.UseVisualStyleBackColor = true; - this.buttonBmfWrite.Click += new System.EventHandler(this.buttonBmfWrite_Click); - // - // buttonBmfRead - // - this.buttonBmfRead.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonBmfRead.Location = new System.Drawing.Point(330, 24); - this.buttonBmfRead.Name = "buttonBmfRead"; - this.buttonBmfRead.Size = new System.Drawing.Size(75, 23); - this.buttonBmfRead.TabIndex = 9; - this.buttonBmfRead.Text = "UID读"; - this.buttonBmfRead.UseVisualStyleBackColor = true; - this.buttonBmfRead.Click += new System.EventHandler(this.buttonBmfRead_Click); - // - // buttonMfoc - // - this.buttonMfoc.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonMfoc.Location = new System.Drawing.Point(249, 53); - this.buttonMfoc.Name = "buttonMfoc"; - this.buttonMfoc.Size = new System.Drawing.Size(75, 23); - this.buttonMfoc.TabIndex = 8; - this.buttonMfoc.Text = "MFOC读"; - this.toolTipHelp.SetToolTip(this.buttonMfoc, "按住Ctrl点击该按钮可添加已知密钥。"); - this.buttonMfoc.UseVisualStyleBackColor = true; - this.buttonMfoc.Click += new System.EventHandler(this.buttonMfoc_Click); - // - // buttonUidWrite - // - this.buttonUidWrite.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonUidWrite.Location = new System.Drawing.Point(168, 53); - this.buttonUidWrite.Name = "buttonUidWrite"; - this.buttonUidWrite.Size = new System.Drawing.Size(75, 23); - this.buttonUidWrite.TabIndex = 5; - this.buttonUidWrite.Text = "UID写号"; - this.buttonUidWrite.UseVisualStyleBackColor = true; - this.buttonUidWrite.Click += new System.EventHandler(this.buttonUidWrite_Click); - // - // buttonUidFormat - // - this.buttonUidFormat.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonUidFormat.Location = new System.Drawing.Point(249, 24); - this.buttonUidFormat.Name = "buttonUidFormat"; - this.buttonUidFormat.Size = new System.Drawing.Size(75, 23); - this.buttonUidFormat.TabIndex = 7; - this.buttonUidFormat.Text = "UID全格"; - this.buttonUidFormat.UseVisualStyleBackColor = true; - this.buttonUidFormat.Click += new System.EventHandler(this.buttonUidFormat_Click); - // - // buttonUidReset - // - this.buttonUidReset.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonUidReset.Location = new System.Drawing.Point(168, 24); - this.buttonUidReset.Name = "buttonUidReset"; - this.buttonUidReset.Size = new System.Drawing.Size(75, 23); - this.buttonUidReset.TabIndex = 6; - this.buttonUidReset.Text = "UID重置"; - this.buttonUidReset.UseVisualStyleBackColor = true; - this.buttonUidReset.Click += new System.EventHandler(this.buttonUidReset_Click); + this.buttonMfFormat.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonMfFormat.Location = new System.Drawing.Point(112, 24); + this.buttonMfFormat.Name = "buttonMfFormat"; + this.buttonMfFormat.Size = new System.Drawing.Size(50, 23); + this.buttonMfFormat.TabIndex = 6; + this.buttonMfFormat.Text = "清M1"; + this.buttonMfFormat.UseVisualStyleBackColor = true; + this.buttonMfFormat.Click += new System.EventHandler(this.buttonMfFormat_Click); // // buttonMfWrite // this.buttonMfWrite.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonMfWrite.Location = new System.Drawing.Point(87, 24); + this.buttonMfWrite.Location = new System.Drawing.Point(59, 24); this.buttonMfWrite.Name = "buttonMfWrite"; - this.buttonMfWrite.Size = new System.Drawing.Size(75, 23); + this.buttonMfWrite.Size = new System.Drawing.Size(50, 23); this.buttonMfWrite.TabIndex = 5; - this.buttonMfWrite.Text = "写M1卡"; + this.buttonMfWrite.Text = "写M1"; this.buttonMfWrite.UseVisualStyleBackColor = true; this.buttonMfWrite.Click += new System.EventHandler(this.buttonMfWrite_Click); // @@ -283,14 +233,81 @@ this.buttonSelectKey.UseVisualStyleBackColor = true; this.buttonSelectKey.Click += new System.EventHandler(this.buttonSelectKey_Click); // + // buttonBmfWrite + // + this.buttonBmfWrite.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonBmfWrite.Location = new System.Drawing.Point(6, 53); + this.buttonBmfWrite.Name = "buttonBmfWrite"; + this.buttonBmfWrite.Size = new System.Drawing.Size(75, 23); + this.buttonBmfWrite.TabIndex = 10; + this.buttonBmfWrite.Text = "UID写"; + this.buttonBmfWrite.UseVisualStyleBackColor = true; + this.buttonBmfWrite.Click += new System.EventHandler(this.buttonBmfWrite_Click); + // + // buttonBmfRead + // + this.buttonBmfRead.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonBmfRead.Location = new System.Drawing.Point(6, 24); + this.buttonBmfRead.Name = "buttonBmfRead"; + this.buttonBmfRead.Size = new System.Drawing.Size(75, 23); + this.buttonBmfRead.TabIndex = 9; + this.buttonBmfRead.Text = "UID读"; + this.buttonBmfRead.UseVisualStyleBackColor = true; + this.buttonBmfRead.Click += new System.EventHandler(this.buttonBmfRead_Click); + // + // buttonMfoc + // + this.buttonMfoc.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonMfoc.Location = new System.Drawing.Point(6, 22); + this.buttonMfoc.Name = "buttonMfoc"; + this.buttonMfoc.Size = new System.Drawing.Size(75, 23); + this.buttonMfoc.TabIndex = 8; + this.buttonMfoc.Text = "MFOC读"; + this.toolTipHelp.SetToolTip(this.buttonMfoc, "按住Ctrl点击该按钮可添加已知密钥。"); + this.buttonMfoc.UseVisualStyleBackColor = true; + this.buttonMfoc.Click += new System.EventHandler(this.buttonMfoc_Click); + // + // buttonUidWrite + // + this.buttonUidWrite.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonUidWrite.Location = new System.Drawing.Point(84, 53); + this.buttonUidWrite.Name = "buttonUidWrite"; + this.buttonUidWrite.Size = new System.Drawing.Size(75, 23); + this.buttonUidWrite.TabIndex = 5; + this.buttonUidWrite.Text = "UID写号"; + this.buttonUidWrite.UseVisualStyleBackColor = true; + this.buttonUidWrite.Click += new System.EventHandler(this.buttonUidWrite_Click); + // + // buttonUidFormat + // + this.buttonUidFormat.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonUidFormat.Location = new System.Drawing.Point(162, 24); + this.buttonUidFormat.Name = "buttonUidFormat"; + this.buttonUidFormat.Size = new System.Drawing.Size(75, 23); + this.buttonUidFormat.TabIndex = 7; + this.buttonUidFormat.Text = "UID全格"; + this.buttonUidFormat.UseVisualStyleBackColor = true; + this.buttonUidFormat.Click += new System.EventHandler(this.buttonUidFormat_Click); + // + // buttonUidReset + // + this.buttonUidReset.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonUidReset.Location = new System.Drawing.Point(84, 24); + this.buttonUidReset.Name = "buttonUidReset"; + this.buttonUidReset.Size = new System.Drawing.Size(75, 23); + this.buttonUidReset.TabIndex = 6; + this.buttonUidReset.Text = "UID重置"; + this.buttonUidReset.UseVisualStyleBackColor = true; + this.buttonUidReset.Click += new System.EventHandler(this.buttonUidReset_Click); + // // groupBox3 // this.groupBox3.Controls.Add(this.buttonKill); this.groupBox3.Controls.Add(this.buttonConSave); this.groupBox3.Controls.Add(this.buttonConClr); - this.groupBox3.Location = new System.Drawing.Point(458, 95); + this.groupBox3.Location = new System.Drawing.Point(587, 94); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(169, 83); + this.groupBox3.Size = new System.Drawing.Size(169, 84); this.groupBox3.TabIndex = 5; this.groupBox3.TabStop = false; this.groupBox3.Text = "运行/终端"; @@ -298,7 +315,7 @@ // buttonKill // this.buttonKill.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonKill.Location = new System.Drawing.Point(6, 53); + this.buttonKill.Location = new System.Drawing.Point(6, 52); this.buttonKill.Name = "buttonKill"; this.buttonKill.Size = new System.Drawing.Size(75, 23); this.buttonKill.TabIndex = 2; @@ -309,7 +326,7 @@ // buttonConSave // this.buttonConSave.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonConSave.Location = new System.Drawing.Point(87, 24); + this.buttonConSave.Location = new System.Drawing.Point(87, 23); this.buttonConSave.Name = "buttonConSave"; this.buttonConSave.Size = new System.Drawing.Size(75, 23); this.buttonConSave.TabIndex = 1; @@ -320,7 +337,7 @@ // buttonConClr // this.buttonConClr.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonConClr.Location = new System.Drawing.Point(6, 24); + this.buttonConClr.Location = new System.Drawing.Point(6, 23); this.buttonConClr.Name = "buttonConClr"; this.buttonConClr.Size = new System.Drawing.Size(75, 23); this.buttonConClr.TabIndex = 0; @@ -331,18 +348,18 @@ // buttonMfcuk // this.buttonMfcuk.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonMfcuk.Location = new System.Drawing.Point(122, 24); + this.buttonMfcuk.Location = new System.Drawing.Point(178, 23); this.buttonMfcuk.Name = "buttonMfcuk"; - this.buttonMfcuk.Size = new System.Drawing.Size(70, 52); + this.buttonMfcuk.Size = new System.Drawing.Size(104, 22); this.buttonMfcuk.TabIndex = 3; - this.buttonMfcuk.Text = "MFCUK\r\n爆密钥"; + this.buttonMfcuk.Text = "全加密爆破"; this.buttonMfcuk.UseVisualStyleBackColor = true; this.buttonMfcuk.Click += new System.EventHandler(this.buttonMfcuk_Click); // // buttonHexTool // this.buttonHexTool.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonHexTool.Location = new System.Drawing.Point(6, 53); + this.buttonHexTool.Location = new System.Drawing.Point(4, 52); this.buttonHexTool.Name = "buttonHexTool"; this.buttonHexTool.Size = new System.Drawing.Size(110, 23); this.buttonHexTool.TabIndex = 1; @@ -352,14 +369,14 @@ // // buttonDiffTool // - this.buttonDiffTool.Enabled = false; this.buttonDiffTool.Font = new System.Drawing.Font("宋体", 8.5F); - this.buttonDiffTool.Location = new System.Drawing.Point(6, 24); + this.buttonDiffTool.Location = new System.Drawing.Point(4, 23); this.buttonDiffTool.Name = "buttonDiffTool"; this.buttonDiffTool.Size = new System.Drawing.Size(110, 23); this.buttonDiffTool.TabIndex = 0; this.buttonDiffTool.Text = "差异比较"; this.buttonDiffTool.UseVisualStyleBackColor = true; + this.buttonDiffTool.Click += new System.EventHandler(this.buttonDiffTool_Click); // // toolTipHelp // @@ -371,24 +388,19 @@ // // groupBox4 // - this.groupBox4.Controls.Add(this.buttonCheckEncrypt); - this.groupBox4.Controls.Add(this.buttonEnAcr122u); - this.groupBox4.Controls.Add(this.buttonMfFormat); - this.groupBox4.Controls.Add(this.buttonLockUfuid); - this.groupBox4.Controls.Add(this.buttonCmfWrite); - this.groupBox4.Controls.Add(this.buttonMfcuk); this.groupBox4.Controls.Add(this.buttonDiffTool); this.groupBox4.Controls.Add(this.buttonHexTool); - this.groupBox4.Location = new System.Drawing.Point(3, 95); + this.groupBox4.Location = new System.Drawing.Point(3, 94); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(449, 83); + this.groupBox4.Size = new System.Drawing.Size(282, 83); this.groupBox4.TabIndex = 11; this.groupBox4.TabStop = false; - this.groupBox4.Text = "工具"; + this.groupBox4.Text = "集成辅助工具"; // // buttonCheckEncrypt // - this.buttonCheckEncrypt.Location = new System.Drawing.Point(360, 23); + this.buttonCheckEncrypt.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonCheckEncrypt.Location = new System.Drawing.Point(6, 51); this.buttonCheckEncrypt.Name = "buttonCheckEncrypt"; this.buttonCheckEncrypt.Size = new System.Drawing.Size(75, 23); this.buttonCheckEncrypt.TabIndex = 13; @@ -396,29 +408,10 @@ this.buttonCheckEncrypt.UseVisualStyleBackColor = true; this.buttonCheckEncrypt.Click += new System.EventHandler(this.buttonCheckEncrypt_Click); // - // buttonEnAcr122u - // - this.buttonEnAcr122u.Location = new System.Drawing.Point(279, 52); - this.buttonEnAcr122u.Name = "buttonEnAcr122u"; - this.buttonEnAcr122u.Size = new System.Drawing.Size(156, 23); - this.buttonEnAcr122u.TabIndex = 7; - this.buttonEnAcr122u.Text = "启用ACR122U支持"; - this.buttonEnAcr122u.UseVisualStyleBackColor = true; - this.buttonEnAcr122u.Click += new System.EventHandler(this.buttonEnAcr122u_Click); - // - // buttonMfFormat - // - this.buttonMfFormat.Location = new System.Drawing.Point(279, 23); - this.buttonMfFormat.Name = "buttonMfFormat"; - this.buttonMfFormat.Size = new System.Drawing.Size(75, 23); - this.buttonMfFormat.TabIndex = 6; - this.buttonMfFormat.Text = "清M1卡"; - this.buttonMfFormat.UseVisualStyleBackColor = true; - this.buttonMfFormat.Click += new System.EventHandler(this.buttonMfFormat_Click); - // // buttonLockUfuid // - this.buttonLockUfuid.Location = new System.Drawing.Point(198, 52); + this.buttonLockUfuid.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonLockUfuid.Location = new System.Drawing.Point(162, 53); this.buttonLockUfuid.Name = "buttonLockUfuid"; this.buttonLockUfuid.Size = new System.Drawing.Size(75, 23); this.buttonLockUfuid.TabIndex = 5; @@ -428,7 +421,8 @@ // // buttonCmfWrite // - this.buttonCmfWrite.Location = new System.Drawing.Point(198, 23); + this.buttonCmfWrite.Font = new System.Drawing.Font("宋体", 8.5F); + this.buttonCmfWrite.Location = new System.Drawing.Point(25, 53); this.buttonCmfWrite.Name = "buttonCmfWrite"; this.buttonCmfWrite.Size = new System.Drawing.Size(75, 23); this.buttonCmfWrite.TabIndex = 4; @@ -440,10 +434,10 @@ // this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage1); - this.tabControl1.Location = new System.Drawing.Point(5, 5); + this.tabControl1.Location = new System.Drawing.Point(0, 5); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(640, 212); + this.tabControl1.Size = new System.Drawing.Size(767, 212); this.tabControl1.TabIndex = 11; // // tabPage2 @@ -455,7 +449,7 @@ this.tabPage2.Location = new System.Drawing.Point(4, 25); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(632, 183); + this.tabPage2.Size = new System.Drawing.Size(759, 183); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "复制卡模式"; this.tabPage2.UseVisualStyleBackColor = true; @@ -630,6 +624,9 @@ // // tabPage1 // + this.tabPage1.Controls.Add(this.groupBox10); + this.tabPage1.Controls.Add(this.groupBox9); + this.tabPage1.Controls.Add(this.groupBox8); this.tabPage1.Controls.Add(this.groupBox1); this.tabPage1.Controls.Add(this.groupBox4); this.tabPage1.Controls.Add(this.groupBox2); @@ -637,21 +634,83 @@ this.tabPage1.Location = new System.Drawing.Point(4, 25); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(632, 183); + this.tabPage1.Size = new System.Drawing.Size(759, 183); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "高级操作模式"; this.tabPage1.UseVisualStyleBackColor = true; // + // groupBox10 + // + this.groupBox10.Controls.Add(this.buttonDictMfoc); + this.groupBox10.Controls.Add(this.buttonnKeysMfoc); + this.groupBox10.Controls.Add(this.buttonHardNested); + this.groupBox10.Controls.Add(this.buttonMfcuk); + this.groupBox10.Controls.Add(this.buttonCheckEncrypt); + this.groupBox10.Controls.Add(this.buttonMfoc); + this.groupBox10.Location = new System.Drawing.Point(291, 94); + this.groupBox10.Name = "groupBox10"; + this.groupBox10.Size = new System.Drawing.Size(290, 83); + this.groupBox10.TabIndex = 6; + this.groupBox10.TabStop = false; + this.groupBox10.Text = "破解工具"; + // + // buttonHardNested + // + this.buttonHardNested.Enabled = false; + this.buttonHardNested.Location = new System.Drawing.Point(178, 51); + this.buttonHardNested.Name = "buttonHardNested"; + this.buttonHardNested.Size = new System.Drawing.Size(104, 23); + this.buttonHardNested.TabIndex = 14; + this.buttonHardNested.Text = "HardNested"; + this.buttonHardNested.UseVisualStyleBackColor = true; + // + // groupBox9 + // + this.groupBox9.Controls.Add(this.label1); + this.groupBox9.Controls.Add(this.buttonCmfWrite); + this.groupBox9.Location = new System.Drawing.Point(633, 6); + this.groupBox9.Name = "groupBox9"; + this.groupBox9.Size = new System.Drawing.Size(123, 83); + this.groupBox9.TabIndex = 14; + this.groupBox9.TabStop = false; + this.groupBox9.Text = "C/FUID卡操作"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(22, 19); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(82, 30); + this.label1.TabIndex = 5; + this.label1.Text = "该卡种读取\r\n同普通卡"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // groupBox8 + // + this.groupBox8.Controls.Add(this.buttonBmfWrite); + this.groupBox8.Controls.Add(this.buttonBmfRead); + this.groupBox8.Controls.Add(this.buttonLockUfuid); + this.groupBox8.Controls.Add(this.buttonUidWrite); + this.groupBox8.Controls.Add(this.buttonUidFormat); + this.groupBox8.Controls.Add(this.buttonUidReset); + this.groupBox8.Location = new System.Drawing.Point(384, 6); + this.groupBox8.Name = "groupBox8"; + this.groupBox8.Size = new System.Drawing.Size(244, 83); + this.groupBox8.TabIndex = 6; + this.groupBox8.TabStop = false; + this.groupBox8.Text = "UID/UFUID卡操作"; + // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.statusLabel, this.runTimeLabel, this.localVersionLabel, - this.remoteVersionLabel}); + this.remoteVersionLabel, + this.toolStripCheckUpdate}); this.statusStrip1.Location = new System.Drawing.Point(0, 522); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(649, 26); + this.statusStrip1.Size = new System.Drawing.Size(767, 26); this.statusStrip1.TabIndex = 12; this.statusStrip1.Text = "statusStrip1"; // @@ -671,27 +730,58 @@ // // localVersionLabel // + this.localVersionLabel.AutoSize = false; this.localVersionLabel.Name = "localVersionLabel"; - this.localVersionLabel.Size = new System.Drawing.Size(0, 21); + this.localVersionLabel.Size = new System.Drawing.Size(125, 21); this.localVersionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // remoteVersionLabel // this.remoteVersionLabel.AutoSize = false; this.remoteVersionLabel.Name = "remoteVersionLabel"; - this.remoteVersionLabel.Size = new System.Drawing.Size(130, 21); + this.remoteVersionLabel.Size = new System.Drawing.Size(125, 21); this.remoteVersionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // + // toolStripCheckUpdate + // + this.toolStripCheckUpdate.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.toolStripCheckUpdate.Image = ((System.Drawing.Image)(resources.GetObject("toolStripCheckUpdate.Image"))); + this.toolStripCheckUpdate.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripCheckUpdate.Name = "toolStripCheckUpdate"; + this.toolStripCheckUpdate.Size = new System.Drawing.Size(85, 24); + this.toolStripCheckUpdate.Text = "检查更新"; + this.toolStripCheckUpdate.ButtonClick += new System.EventHandler(this.toolStripCheckUpdate_ButtonClick); + // // timer1 // this.timer1.Enabled = true; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // + // buttonnKeysMfoc + // + this.buttonnKeysMfoc.Location = new System.Drawing.Point(87, 22); + this.buttonnKeysMfoc.Name = "buttonnKeysMfoc"; + this.buttonnKeysMfoc.Size = new System.Drawing.Size(85, 23); + this.buttonnKeysMfoc.TabIndex = 15; + this.buttonnKeysMfoc.Text = "知n密"; + this.buttonnKeysMfoc.UseVisualStyleBackColor = true; + this.buttonnKeysMfoc.Click += new System.EventHandler(this.buttonnKeysMfoc_Click); + // + // buttonDictMfoc + // + this.buttonDictMfoc.Location = new System.Drawing.Point(87, 51); + this.buttonDictMfoc.Name = "buttonDictMfoc"; + this.buttonDictMfoc.Size = new System.Drawing.Size(85, 23); + this.buttonDictMfoc.TabIndex = 16; + this.buttonDictMfoc.Text = "字典测试"; + this.buttonDictMfoc.UseVisualStyleBackColor = true; + this.buttonDictMfoc.Click += new System.EventHandler(this.buttonDictMfoc_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(649, 548); + this.ClientSize = new System.Drawing.Size(767, 548); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.tabControl1); this.Controls.Add(this.richTextBox1); @@ -701,7 +791,6 @@ this.Text = "MifareOne Tool"; this.Load += new System.EventHandler(this.Form1_Load); this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.groupBox4.ResumeLayout(false); @@ -711,6 +800,10 @@ this.groupBox6.ResumeLayout(false); this.groupBox5.ResumeLayout(false); this.tabPage1.ResumeLayout(false); + this.groupBox10.ResumeLayout(false); + this.groupBox9.ResumeLayout(false); + this.groupBox9.PerformLayout(); + this.groupBox8.ResumeLayout(false); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.ResumeLayout(false); @@ -739,7 +832,6 @@ private System.Windows.Forms.Button buttonConSave; private System.Windows.Forms.Button buttonConClr; private System.Windows.Forms.Button buttonKill; - private System.Windows.Forms.LinkLabel linkLabel1; private System.Windows.Forms.Button buttonDiffTool; private System.Windows.Forms.Button buttonHexTool; private System.Windows.Forms.Button buttonMfcuk; @@ -775,6 +867,14 @@ private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Button buttonCheckEncrypt; private System.Windows.Forms.Button buttonECheckEncrypt; + private System.Windows.Forms.GroupBox groupBox10; + private System.Windows.Forms.Button buttonHardNested; + private System.Windows.Forms.GroupBox groupBox9; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.GroupBox groupBox8; + private System.Windows.Forms.ToolStripSplitButton toolStripCheckUpdate; + private System.Windows.Forms.Button buttonDictMfoc; + private System.Windows.Forms.Button buttonnKeysMfoc; } } diff --git a/MifareOneTool/Form1.cs b/MifareOneTool/Form1.cs index 8c81f5c..606c00d 100644 --- a/MifareOneTool/Form1.cs +++ b/MifareOneTool/Form1.cs @@ -12,6 +12,7 @@ using System.Security.Cryptography; using System.Text.RegularExpressions; using Microsoft.VisualBasic; using System.Reflection; +using System.Runtime.InteropServices; namespace MifareOneTool { @@ -28,7 +29,7 @@ namespace MifareOneTool private void buttonListDev_Click(object sender, EventArgs e) { - if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } + if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(list_dev); @@ -77,7 +78,7 @@ namespace MifareOneTool omfd = ""; Text = "MifareOne Tool - 运行完毕"; } - Application.DoEvents(); + Application.DoEvents(); } @@ -97,7 +98,7 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; @@ -105,15 +106,17 @@ namespace MifareOneTool process.BeginErrorReadLine(); process.WaitForExit(); lprocess = false; - running=false; + running = false; b.ReportProgress(100, "##运行完毕##"); } private void Form1_Load(object sender, EventArgs e) { - linkLabel1.Links.Add(0, linkLabel1.Text.Length, "https://github.com/xcicode/MifareOneTool/releases/latest"); logAppend("#软件版本 " + Assembly.GetExecutingAssembly().GetName().Version.ToString()); - localVersionLabel.Text="本地版本 " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); + localVersionLabel.Text = "本地版本 " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); + //GitHubUpdate ghu = new GitHubUpdate(Properties.Settings.Default.GitHubR); + //ghu.Update(Properties.Settings.Default.GitHubR); + //remoteVersionLabel.Text = "远程版本 " + ghu.remoteVersion; } private void buttonScanCard_Click(object sender, EventArgs e) @@ -136,14 +139,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } @@ -169,9 +172,9 @@ namespace MifareOneTool bgw.DoWork += new DoWorkEventHandler(mf_read); bgw.WorkerReportsProgress = true; bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); - bgw.RunWorkerAsync(new string[] { rmfd, kt,nn }); + bgw.RunWorkerAsync(new string[] { rmfd, kt, nn }); omfd = rmfd; - + } void mf_read(object sender, DoWorkEventArgs e) @@ -190,14 +193,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; if (process.ExitCode == 0) { b.ReportProgress(101, "##运行完毕##"); @@ -282,18 +285,18 @@ namespace MifareOneTool switch (MessageBox.Show("使用KeyA(是)或KeyB(否),还是不使用(用于全新白卡)(取消)?", "KeyA/B/N", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information)) { case DialogResult.No: - kt = "b"; - break; + kt = "b"; + break; case DialogResult.Cancel: - nn="x"; + nn = "x"; break; } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(mf_write); bgw.WorkerReportsProgress = true; bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); - bgw.RunWorkerAsync(new string[] { rmfd, kt,nn }); + bgw.RunWorkerAsync(new string[] { rmfd, kt, nn }); } void mf_write(object sender, DoWorkEventArgs e) @@ -302,7 +305,7 @@ namespace MifareOneTool ProcessStartInfo psi = new ProcessStartInfo("nfc-bin/nfc-mfclassic.exe"); string[] args = (string[])e.Argument; psi.Arguments = "w " + args[1] + " u \"" + args[0] + "\""; - if (keymfd != "" && args[2]=="") + if (keymfd != "" && args[2] == "") { psi.Arguments += " \"" + keymfd + "\" f"; } @@ -312,42 +315,43 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } private void buttonMfoc_Click(object sender, EventArgs e) { if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; - string rmfd = "Mfoc.tmp"; - string key = ""; - if (Control.ModifierKeys == Keys.Control) + string rmfd = "Mfoc.tmp"; + string key = ""; + if (Control.ModifierKeys == Keys.Control) + { + string[] ks = Interaction.InputBox("请输入已知的Key,以英文半角逗号分隔。", "请输入已知Key", "FFFFFFFFFFFF", -1, -1).Trim().Split(','); + if (ks.Length > 0) { - string[] ks = Interaction.InputBox("请输入已知的Key,以英文半角逗号分隔。", "请输入已知Key", "FFFFFFFFFFFF", -1, -1).Trim().Split(','); - if (ks.Length > 0) + foreach (string k in ks) { - foreach(string k in ks){ - string pat = "[0-9A-Fa-f]{12}"; - if (Regex.IsMatch(k, pat)) - { - key += "-k " + k.Substring(0, 12) + " "; - } + string pat = "[0-9A-Fa-f]{12}"; + if (Regex.IsMatch(k, pat)) + { + key += "-k " + k.Substring(0, 12) + " "; } - } + } } - BackgroundWorker bgw = new BackgroundWorker(); - bgw.DoWork += new DoWorkEventHandler(mfoc); - bgw.WorkerReportsProgress = true; - bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); - bgw.RunWorkerAsync(new string[] { rmfd, key }); - omfd = rmfd; + } + BackgroundWorker bgw = new BackgroundWorker(); + bgw.DoWork += new DoWorkEventHandler(mfoc); + bgw.WorkerReportsProgress = true; + bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); + bgw.RunWorkerAsync(new string[] { rmfd, key }); + omfd = rmfd; } void mfoc(object sender, DoWorkEventArgs e) @@ -362,14 +366,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; if (process.ExitCode == 0) { b.ReportProgress(101, "##运行完毕##"); @@ -416,14 +420,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } @@ -453,14 +457,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } @@ -489,14 +493,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; if (process.ExitCode == 0) { b.ReportProgress(101, "##运行完毕##"); @@ -548,14 +552,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } @@ -614,25 +618,20 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } - private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) - { - Process.Start("https://github.com/xcicode/MifareOneTool/releases/latest"); - } - private void buttonMfcuk_Click(object sender, EventArgs e) { - if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } + if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Text = "MifareOne Tool - 运行中"; BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(Mfcuk); @@ -649,9 +648,9 @@ namespace MifareOneTool psi.WorkingDirectory = "nfc-bin"; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process=Process.Start(psi); + process = Process.Start(psi); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } @@ -708,14 +707,14 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } @@ -745,21 +744,21 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } private void buttonMfFormat_Click(object sender, EventArgs e) { - if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - if (keymfd=="") { MessageBox.Show("未选择有效key.mfd。", "无密钥", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; + if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } + if (keymfd == "") { MessageBox.Show("未选择有效key.mfd。", "无密钥", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; string rmfd = keymfd; string kt = "a"; switch (MessageBox.Show("使用KeyA(是)或KeyB(否)?", "KeyA/B", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) @@ -772,7 +771,7 @@ namespace MifareOneTool bgw.DoWork += new DoWorkEventHandler(mf_format); bgw.WorkerReportsProgress = true; bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); - bgw.RunWorkerAsync(new string[] { rmfd, kt}); + bgw.RunWorkerAsync(new string[] { rmfd, kt }); } void mf_format(object sender, DoWorkEventArgs e) @@ -788,20 +787,20 @@ namespace MifareOneTool psi.RedirectStandardError = true; lprocess = true; BackgroundWorker b = (BackgroundWorker)sender; - process = Process.Start(psi);running=true; + process = Process.Start(psi); running = true; process.OutputDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); process.ErrorDataReceived += (s, _e) => b.ReportProgress(0, _e.Data); //StreamReader stderr = process.StandardError; process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); - lprocess = false;running=false; + lprocess = false; running = false; b.ReportProgress(100, "##运行完毕##"); } private void buttonEMfoc_Click(object sender, EventArgs e) { - buttonMfoc_Click(sender,e); + buttonMfoc_Click(sender, e); } private void buttonEscan_Click(object sender, EventArgs e) @@ -819,18 +818,18 @@ namespace MifareOneTool if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; string rmfd = "Mfoc.tmp"; string key = ""; - string[] ks = Interaction.InputBox("请输入已知的Key,以英文半角逗号分隔。", "请输入已知Key", "FFFFFFFFFFFF", -1, -1).Trim().Split(','); - if (ks.Length > 0) + string[] ks = Interaction.InputBox("请输入已知的Key,以英文半角逗号分隔。", "请输入已知Key", "FFFFFFFFFFFF", -1, -1).Trim().Split(','); + if (ks.Length > 0) + { + foreach (string k in ks) { - foreach (string k in ks) + string pat = "[0-9A-Fa-f]{12}"; + if (Regex.IsMatch(k, pat)) { - string pat = "[0-9A-Fa-f]{12}"; - if (Regex.IsMatch(k, pat)) - { - key += "-k " + k.Substring(0, 12) + " "; - } + key += "-k " + k.Substring(0, 12) + " "; } } + } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += new DoWorkEventHandler(mfoc); bgw.WorkerReportsProgress = true; @@ -841,7 +840,7 @@ namespace MifareOneTool private void buttonEUpdate_Click(object sender, EventArgs e) { - linkLabel1_LinkClicked(sender, null); + toolStripCheckUpdate_ButtonClick(sender, e); } private void buttonESelectKey_Click(object sender, EventArgs e) @@ -878,7 +877,7 @@ namespace MifareOneTool { if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; if (MessageBox.Show("同时打开ACR122U支持可能会引起操作速度下降。\n请确认是否要继续操作?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) - { return; } + { Text = "MifareOne Tool"; return; } lprocess = true; if (File.Exists("nfc-bin/libnfc(PN532Only).dll")) { @@ -891,19 +890,21 @@ namespace MifareOneTool File.Move("nfc-bin/libnfc(ACR122U).dll", "nfc-bin/libnfc.dll"); logAppend("已打开。"); } - lprocess = false;running=false; + lprocess = false; running = false; Text = "MifareOne Tool - 运行完毕"; logAppend("##运行完毕##"); } private void timer1_Tick(object sender, EventArgs e) { - if (running) { + if (running) + { statusLabel.Text = "运行中"; - if(process.HasExited==false){ - DateTime now = DateTime.Now; - TimeSpan runtime = now - process.StartTime; - runTimeLabel.Text = "运行时间:"+((int)runtime.TotalSeconds).ToString()+"秒"; + if (process.HasExited == false) + { + DateTime now = DateTime.Now; + TimeSpan runtime = now - process.StartTime; + runTimeLabel.Text = "运行时间:" + ((int)runtime.TotalSeconds).ToString() + "秒"; } } else { statusLabel.Text = "空闲"; } @@ -959,5 +960,102 @@ namespace MifareOneTool { buttonCheckEncrypt_Click(sender, e); } + + private void toolStripCheckUpdate_ButtonClick(object sender, EventArgs e) + { + Process.Start("https://github.com/xcicode/MifareOneTool/releases/latest"); + } + + private void buttonDiffTool_Click(object sender, EventArgs e) + { + FormDiff df = new FormDiff(); + df.Show(); + } + + private void buttonnKeysMfoc_Click(object sender, EventArgs e) + { + if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; + string rmfd = "Mfoc.tmp"; + string key = ""; + string[] ks = Interaction.InputBox("请输入已知的Key,以英文半角逗号分隔。", "请输入已知Key", "FFFFFFFFFFFF", -1, -1).Trim().Split(','); + if (ks.Length > 0) + { + foreach (string k in ks) + { + string pat = "[0-9A-Fa-f]{12}"; + if (Regex.IsMatch(k, pat)) + { + key += "-k " + k.Substring(0, 12) + " "; + } + } + } + BackgroundWorker bgw = new BackgroundWorker(); + bgw.DoWork += new DoWorkEventHandler(mfoc); + bgw.WorkerReportsProgress = true; + bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); + bgw.RunWorkerAsync(new string[] { rmfd, key }); + omfd = rmfd; + } + + private void buttonDictMfoc_Click(object sender, EventArgs e) + { + if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; + string cmd_mode="/c"; + if (Control.ModifierKeys == Keys.Control) + { + cmd_mode="/k"; + } + string filename = ""; + OpenFileDialog ofd = new OpenFileDialog(); + ofd.CheckFileExists = true; + ofd.Filter = "密钥字典文件|*.dic"; + ofd.Title = "请选择需要打开的密钥字典文件"; + ofd.Multiselect = false; + if (ofd.ShowDialog() == DialogResult.OK) + { + filename=ofd.FileName; + } + else + { + Text = "MifareOne Tool - 已取消"; + return; + } + string rmfd = "Mfoc.tmp"; + string key = "-f " + filename + " "; + BackgroundWorker bgw = new BackgroundWorker(); + bgw.DoWork += new DoWorkEventHandler(mfocCMD); + bgw.WorkerReportsProgress = true; + bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); + bgw.RunWorkerAsync(new string[] { rmfd, key, cmd_mode }); + omfd = rmfd; + } + + [DllImport("user32.dll", EntryPoint = "SetWindowText")] + public static extern int SetWindowText(IntPtr hwnd, string lpString); + [DllImport("user32", SetLastError = true)] + public static extern int GetWindowText(IntPtr hWnd,StringBuilder lpString,int nMaxCount); + + void mfocCMD(object sender, DoWorkEventArgs e) + { + if (lprocess) { return; } + ProcessStartInfo psi = new ProcessStartInfo("cmd.exe"); + string[] args = (string[])e.Argument; + psi.WorkingDirectory = "./"; + psi.Arguments = "/T:0A "+ args[2] + @" nfc-bin\mfoc.exe " + args[1] + " -O \"" + args[0] + "\""; + lprocess = true; + BackgroundWorker b = (BackgroundWorker)sender; + process = Process.Start(psi); running = true; + process.WaitForExit(); + lprocess = false; running = false; + if (process.ExitCode == 0) + { + b.ReportProgress(101, "##运行完毕##"); + } + else + { + b.ReportProgress(100, "##运行出错##"); + File.Delete(args[0]); + } + } } } diff --git a/MifareOneTool/Form1.resx b/MifareOneTool/Form1.resx index e3a46f8..0859143 100644 --- a/MifareOneTool/Form1.resx +++ b/MifareOneTool/Form1.resx @@ -120,9 +120,28 @@ 17, 17 + + 17, 17 + 157, 17 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + 297, 17 diff --git a/MifareOneTool/FormDiff.Designer.cs b/MifareOneTool/FormDiff.Designer.cs index 2a122e5..88f1cf5 100644 --- a/MifareOneTool/FormDiff.Designer.cs +++ b/MifareOneTool/FormDiff.Designer.cs @@ -29,24 +29,70 @@ private void InitializeComponent() { this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // richTextBox1 // - this.richTextBox1.Location = new System.Drawing.Point(12, 43); + this.richTextBox1.BackColor = System.Drawing.Color.Black; + this.richTextBox1.ForeColor = System.Drawing.Color.Orange; + this.richTextBox1.Location = new System.Drawing.Point(12, 74); this.richTextBox1.Name = "richTextBox1"; - this.richTextBox1.Size = new System.Drawing.Size(421, 505); + this.richTextBox1.ReadOnly = true; + this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedVertical; + this.richTextBox1.Size = new System.Drawing.Size(469, 474); this.richTextBox1.TabIndex = 0; - this.richTextBox1.Text = "A: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11"; + this.richTextBox1.Text = "欢迎使用M1T内置的差异工具!\n说明:\n点击上方的AB两个按键分别选择MFD文件。\n然后点击“比较”即可看到结果。\n"; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(12, 12); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(388, 25); + this.button1.TabIndex = 1; + this.button1.Text = "A"; + this.button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(12, 43); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(388, 25); + this.button2.TabIndex = 2; + this.button2.Text = "B"; + this.button2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(406, 12); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 56); + this.button3.TabIndex = 3; + this.button3.Text = "比较"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); // // FormDiff // + this.AcceptButton = this.button3; this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(445, 560); + this.ClientSize = new System.Drawing.Size(493, 560); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); this.Controls.Add(this.richTextBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; this.Name = "FormDiff"; - this.Text = "FormDiff"; + this.Text = "DiffTool"; + this.Load += new System.EventHandler(this.FormDiff_Load); this.ResumeLayout(false); } @@ -54,5 +100,8 @@ #endregion private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; } } \ No newline at end of file diff --git a/MifareOneTool/FormDiff.cs b/MifareOneTool/FormDiff.cs index 19d0be6..d679382 100644 --- a/MifareOneTool/FormDiff.cs +++ b/MifareOneTool/FormDiff.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using System.IO; namespace MifareOneTool { @@ -15,5 +16,115 @@ namespace MifareOneTool { InitializeComponent(); } + + private S50 sa = new S50(); + private S50 sb = new S50(); + private string fa = ""; + private string fb = ""; + + private void button1_Click(object sender, EventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.CheckFileExists = true; + ofd.Filter = "MFD文件|*.mfd;*.dump"; + ofd.Title = "请选择需要打开的MFD文件(比较A)"; + ofd.Multiselect = false; + if (ofd.ShowDialog() == DialogResult.OK) + { + fa = ofd.FileName; + } + else + { + return; + } + sa = new S50(); + try + { + sa.LoadFromMfd(fa); + button1.Text = "A=" + ofd.SafeFileName; + } + catch (IOException ioe) + { + MessageBox.Show(ioe.Message, "打开出错", MessageBoxButtons.OK, MessageBoxIcon.Error); + sa = new S50(); + return; + } + } + + private void FormDiff_Load(object sender, EventArgs e) + { + } + private void logAppend(string msg) + { + richTextBox1.AppendText(msg + "\n"); + richTextBox1.ScrollToCaret(); + } + + private void button2_Click(object sender, EventArgs e) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.CheckFileExists = true; + ofd.Filter = "MFD文件|*.mfd;*.dump"; + ofd.Title = "请选择需要打开的MFD文件(比较B)"; + ofd.Multiselect = false; + if (ofd.ShowDialog() == DialogResult.OK) + { + fb = ofd.FileName; + } + else + { + return; + } + sb = new S50(); + try + { + sb.LoadFromMfd(fb); + button2.Text = "B=" + ofd.SafeFileName; + } + catch (IOException ioe) + { + MessageBox.Show(ioe.Message, "打开出错", MessageBoxButtons.OK, MessageBoxIcon.Error); + sb = new S50(); + return; + } + } + + private void button3_Click(object sender, EventArgs e) + { + if (File.Exists(fa) && File.Exists(fb)) + { + richTextBox1.Clear(); + richTextBox1.Text=Compare(); + } + else + { + logAppend("AB文件中一个或两个无效。"); + } + } + private string Compare() + { + StringBuilder stb = new StringBuilder(); + for (int i = 0; i < 16; i++) + { + stb.AppendLine("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); + stb.AppendLine("扇区 " + i.ToString()); + for (int a = 0; a < 4; a++) + { + string res=""; + for(int b=0;b<16;b++){ + if(sa.Sectors[i].Block[a][b]==sb.Sectors[i].Block[a][b]){ + res+="-- "; + }else{ + res+="## "; + } + } + stb.AppendLine("A: " + Utils.Hex2StrS(sa.Sectors[i].Block[a])); + stb.AppendLine("B: " + Utils.Hex2StrS(sb.Sectors[i].Block[a])); + stb.AppendLine(" " + res); + } + + } + return stb.ToString(); + } } } diff --git a/MifareOneTool/FormHTool.Designer.cs b/MifareOneTool/FormHTool.Designer.cs index a781950..7b528a7 100644 --- a/MifareOneTool/FormHTool.Designer.cs +++ b/MifareOneTool/FormHTool.Designer.cs @@ -44,6 +44,7 @@ this.检查并纠正全卡ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.导出为MCT格式ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.导出密钥字典ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -70,8 +71,8 @@ this.labelCurSec = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.s50BindingSource = new System.Windows.Forms.BindingSource(this.components); - this.导出密钥字典ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); @@ -159,7 +160,8 @@ this.检查并纠正全卡ToolStripMenuItem, this.toolStripSeparator3, this.导出为MCT格式ToolStripMenuItem, - this.导出密钥字典ToolStripMenuItem}); + this.导出密钥字典ToolStripMenuItem, + this.toolStripMenuItem1}); this.工具ToolStripMenuItem.Name = "工具ToolStripMenuItem"; this.工具ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.工具ToolStripMenuItem.Text = "工具"; @@ -206,6 +208,14 @@ this.导出为MCT格式ToolStripMenuItem.Text = "导出为MCT格式"; this.导出为MCT格式ToolStripMenuItem.Click += new System.EventHandler(this.导出为MCT格式ToolStripMenuItem_Click); // + // 导出密钥字典ToolStripMenuItem + // + this.导出密钥字典ToolStripMenuItem.Name = "导出密钥字典ToolStripMenuItem"; + this.导出密钥字典ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); + this.导出密钥字典ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); + this.导出密钥字典ToolStripMenuItem.Text = "导出密钥字典"; + this.导出密钥字典ToolStripMenuItem.Click += new System.EventHandler(this.导出密钥字典ToolStripMenuItem_Click); + // // groupBox1 // this.groupBox1.Controls.Add(this.dataGridView1); @@ -516,18 +526,18 @@ this.richTextBox1.TabIndex = 0; this.richTextBox1.Text = "欢迎使用M1T的集成编辑器S50HTool!\n打开文件请点左上角文件-打开或Ctrl+O\n"; // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(248, 24); + this.toolStripMenuItem1.Text = "toolStripMenuItem1"; + this.toolStripMenuItem1.Visible = false; + this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click); + // // s50BindingSource // this.s50BindingSource.DataSource = typeof(MifareOneTool.S50); // - // 导出密钥字典ToolStripMenuItem - // - this.导出密钥字典ToolStripMenuItem.Name = "导出密钥字典ToolStripMenuItem"; - this.导出密钥字典ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.导出密钥字典ToolStripMenuItem.Size = new System.Drawing.Size(248, 24); - this.导出密钥字典ToolStripMenuItem.Text = "导出密钥字典"; - this.导出密钥字典ToolStripMenuItem.Click += new System.EventHandler(this.导出密钥字典ToolStripMenuItem_Click); - // // FormHTool // this.AcceptButton = this.buttonSaveSectorEdit; @@ -601,5 +611,6 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem 导出为MCT格式ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 导出密钥字典ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; } } \ No newline at end of file diff --git a/MifareOneTool/FormHTool.cs b/MifareOneTool/FormHTool.cs index 093b514..978be9f 100644 --- a/MifareOneTool/FormHTool.cs +++ b/MifareOneTool/FormHTool.cs @@ -447,5 +447,20 @@ namespace MifareOneTool File.WriteAllLines(filename, this.currentS50.KeyListStr().ToArray()); logAppend("已导出密钥字典文件" + filename + "。"); } + + private void toolStripMenuItem1_Click(object sender, EventArgs e) + {//测试后门 + StreamWriter sw = File.CreateText("x.dic"); + for (int i = 0; i < 4000 * 32; i++) + { + RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); + byte[] keyn = new byte[6]; + rng.GetBytes(keyn); + sw.WriteLine(Utils.Hex2Str(keyn)); + sw.Flush(); + } + sw.Flush(); + sw.Close(); + } } } diff --git a/MifareOneTool/GitHubUpdate.cs b/MifareOneTool/GitHubUpdate.cs index 66d5e83..75a4bb6 100644 --- a/MifareOneTool/GitHubUpdate.cs +++ b/MifareOneTool/GitHubUpdate.cs @@ -12,8 +12,37 @@ namespace MifareOneTool { class GitHubUpdate { - Version localVersion; - Version remoteVersion; + public Version localVersion; + public string remoteVersion="未知"; + public void Update(string GitHubR) + { + try + {//.net4.5可用 + //处理HttpWebRequest访问https有安全证书的问题( 请求被中止: 未能创建 SSL/TLS 安全通道。) + //System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + + var request = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/" + GitHubR + "/releases/latest"); + var response = (HttpWebResponse)request.GetResponse(); + var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); + JObject jo = JObject.Parse(responseString); + if (jo.GetValue("message") == null) + { + dynamic json = Newtonsoft.Json.Linq.JToken.Parse(responseString) as dynamic; + if (json.prerelease == false) + { + this.remoteVersion = (string)json.tag_name; + } + } + else + { + Console.Error.WriteLine("GitHub更新失效"); + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + } public GitHubUpdate(string GitHubR) { this.localVersion = Assembly.GetExecutingAssembly().GetName().Version; @@ -27,7 +56,7 @@ namespace MifareOneTool { dynamic json = Newtonsoft.Json.Linq.JToken.Parse(responseString) as dynamic; if(json.prerelease==false){ - ; + this.remoteVersion=(string)json.tag_name; } } else diff --git a/MifareOneTool/MifareOneTool.csproj b/MifareOneTool/MifareOneTool.csproj index 6494404..dda007c 100644 --- a/MifareOneTool/MifareOneTool.csproj +++ b/MifareOneTool/MifareOneTool.csproj @@ -56,6 +56,7 @@ + diff --git a/MifareOneTool/Properties/AssemblyInfo.cs b/MifareOneTool/Properties/AssemblyInfo.cs index d772b25..2f1a6aa 100644 --- a/MifareOneTool/Properties/AssemblyInfo.cs +++ b/MifareOneTool/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.2.0")] -[assembly: AssemblyFileVersion("1.5.2.0")] +[assembly: AssemblyVersion("1.6.0.0")] +[assembly: AssemblyFileVersion("1.6.0.0")]