diff --git a/MifareOneTool/Form1.Designer.cs b/MifareOneTool/Form1.Designer.cs index 102a1ff..1ae0ea4 100644 --- a/MifareOneTool/Form1.Designer.cs +++ b/MifareOneTool/Form1.Designer.cs @@ -92,6 +92,7 @@ this.groupBox8 = new System.Windows.Forms.GroupBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.groupBox13 = new System.Windows.Forms.GroupBox(); + this.checkBoxAutoSave = new System.Windows.Forms.CheckBox(); this.checkBoxDefIsAdv = new System.Windows.Forms.CheckBox(); this.groupBox12 = new System.Windows.Forms.GroupBox(); this.numericCLIFontSize = new System.Windows.Forms.NumericUpDown(); @@ -109,7 +110,8 @@ this.remoteVersionLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripCheckUpdate = new System.Windows.Forms.ToolStripSplitButton(); this.timer1 = new System.Windows.Forms.Timer(this.components); - this.checkBoxAutoSave = new System.Windows.Forms.CheckBox(); + this.groupBox11 = new System.Windows.Forms.GroupBox(); + this.checkBoxHardLowCost = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -128,6 +130,7 @@ ((System.ComponentModel.ISupportInitialize)(this.numericCLIFontSize)).BeginInit(); this.groupBox6.SuspendLayout(); this.statusStrip1.SuspendLayout(); + this.groupBox11.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -816,6 +819,7 @@ // // tabPage3 // + this.tabPage3.Controls.Add(this.groupBox11); this.tabPage3.Controls.Add(this.groupBox13); this.tabPage3.Controls.Add(this.groupBox12); this.tabPage3.Controls.Add(this.groupBox6); @@ -837,6 +841,17 @@ this.groupBox13.TabStop = false; this.groupBox13.Text = "偏好设置"; // + // checkBoxAutoSave + // + this.checkBoxAutoSave.AutoSize = true; + this.checkBoxAutoSave.Location = new System.Drawing.Point(9, 46); + this.checkBoxAutoSave.Name = "checkBoxAutoSave"; + this.checkBoxAutoSave.Size = new System.Drawing.Size(173, 19); + this.checkBoxAutoSave.TabIndex = 1; + this.checkBoxAutoSave.Text = "自动以UID名保存文件"; + this.checkBoxAutoSave.UseVisualStyleBackColor = true; + this.checkBoxAutoSave.CheckedChanged += new System.EventHandler(this.checkBoxAutoSave_CheckedChanged); + // // checkBoxDefIsAdv // this.checkBoxDefIsAdv.AutoSize = true; @@ -1022,16 +1037,26 @@ this.timer1.Enabled = true; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); // - // checkBoxAutoSave + // groupBox11 // - this.checkBoxAutoSave.AutoSize = true; - this.checkBoxAutoSave.Location = new System.Drawing.Point(9, 46); - this.checkBoxAutoSave.Name = "checkBoxAutoSave"; - this.checkBoxAutoSave.Size = new System.Drawing.Size(173, 19); - this.checkBoxAutoSave.TabIndex = 1; - this.checkBoxAutoSave.Text = "自动以UID名保存文件"; - this.checkBoxAutoSave.UseVisualStyleBackColor = true; - this.checkBoxAutoSave.CheckedChanged += new System.EventHandler(this.checkBoxAutoSave_CheckedChanged); + this.groupBox11.Controls.Add(this.checkBoxHardLowCost); + this.groupBox11.Location = new System.Drawing.Point(209, 89); + this.groupBox11.Name = "groupBox11"; + this.groupBox11.Size = new System.Drawing.Size(200, 91); + this.groupBox11.TabIndex = 14; + this.groupBox11.TabStop = false; + this.groupBox11.Text = "HardNested"; + // + // checkBoxHardLowCost + // + this.checkBoxHardLowCost.AutoSize = true; + this.checkBoxHardLowCost.Location = new System.Drawing.Point(9, 24); + this.checkBoxHardLowCost.Name = "checkBoxHardLowCost"; + this.checkBoxHardLowCost.Size = new System.Drawing.Size(104, 19); + this.checkBoxHardLowCost.TabIndex = 0; + this.checkBoxHardLowCost.Text = "单线程计算"; + this.checkBoxHardLowCost.UseVisualStyleBackColor = true; + this.checkBoxHardLowCost.CheckedChanged += new System.EventHandler(this.checkBoxHardLowCost_CheckedChanged); // // Form1 // @@ -1072,6 +1097,8 @@ this.groupBox6.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + this.groupBox11.ResumeLayout(false); + this.groupBox11.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1159,6 +1186,8 @@ private System.Windows.Forms.GroupBox groupBox13; private System.Windows.Forms.CheckBox checkBoxDefIsAdv; private System.Windows.Forms.CheckBox checkBoxAutoSave; + private System.Windows.Forms.GroupBox groupBox11; + private System.Windows.Forms.CheckBox checkBoxHardLowCost; } } diff --git a/MifareOneTool/Form1.cs b/MifareOneTool/Form1.cs index 3f8f7a8..b67d477 100644 --- a/MifareOneTool/Form1.cs +++ b/MifareOneTool/Form1.cs @@ -52,7 +52,7 @@ namespace MifareOneTool if (File.Exists(omfd) && new FileInfo(omfd).Length > 1) { Directory.CreateDirectory("auto_keys"); - string filename = "auto_keys\\" + lastuid + "_" + DateTime.Now.ToString().Replace("/","-").Replace(" ","_").Replace(":","-") + ".mfd"; + string filename = "auto_keys\\" + lastuid + "_" + DateTime.Now.ToString().Replace("/", "-").Replace(" ", "_").Replace(":", "-") + ".mfd"; if (File.Exists(filename)) { File.Delete(filename); @@ -101,6 +101,21 @@ namespace MifareOneTool omfd = ""; Text = "MifareOne Tool - 运行完毕"; } + else if (e.ProgressPercentage == 102) + { + string noncefile = lastuid; + lastuid = ""; + if (File.Exists(noncefile)) + { + logAppend("##Nonce收集完毕-" + noncefile + "##"); + logAppend("您可以在本地计算,或是上传到云计算服务节点进行计算。"); + } + else + { + logAppend("##Nonce收集出错##"); + } + Text = "MifareOne Tool - 运行完毕"; + } Application.DoEvents(); } @@ -147,6 +162,7 @@ namespace MifareOneTool richTextBox1.ForeColor = Properties.Settings.Default.MainCLIColor; buttonCLIColor.ForeColor = Properties.Settings.Default.MainCLIColor; checkBoxDefIsAdv.Checked = Properties.Settings.Default.DefIsAdv; + checkBoxHardLowCost.Checked = Properties.Settings.Default.HardLowCost; if (Properties.Settings.Default.DefIsAdv) { tabControl1.SelectedIndex = 1; @@ -1226,7 +1242,15 @@ namespace MifareOneTool { string hardargs = fhn.GetArg(); BackgroundWorker bgw = new BackgroundWorker(); - bgw.DoWork += new DoWorkEventHandler(Hardnest); + if (fhn.collectOnly()) + { + lastuid = "0x" + GetUID() + fhn.GetFileAfter(); + bgw.DoWork += new DoWorkEventHandler(CollectNonce); + } + else + { + bgw.DoWork += new DoWorkEventHandler(Hardnest); + } bgw.WorkerReportsProgress = true; bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt); bgw.RunWorkerAsync(hardargs); @@ -1240,6 +1264,10 @@ namespace MifareOneTool { if (lprocess) { return; } ProcessStartInfo psi = new ProcessStartInfo("nfc-bin/libnfc_hardnested.exe"); + if (Properties.Settings.Default.HardLowCost) + { + psi.FileName = "nfc-bin/libnfc_hardnestedlc.exe"; + } psi.Arguments = (string)e.Argument; psi.CreateNoWindow = true; psi.UseShellExecute = false; @@ -1265,6 +1293,35 @@ namespace MifareOneTool } } + void CollectNonce(object sender, DoWorkEventArgs e) + { + if (lprocess) { return; } + ProcessStartInfo psi = new ProcessStartInfo("nfc-bin/collect.exe"); + psi.Arguments = (string)e.Argument; + psi.CreateNoWindow = true; + psi.UseShellExecute = false; + psi.RedirectStandardOutput = true; + psi.RedirectStandardError = true; + lprocess = true; + BackgroundWorker b = (BackgroundWorker)sender; + 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; + if (process.ExitCode == 0) + { + b.ReportProgress(102, "##运行完毕##"); + } + else + { + b.ReportProgress(100, "##运行出错##"); + } + } + private void checkBoxAutoLoadKey_CheckedChanged(object sender, EventArgs e) { Properties.Settings.Default.AutoLoadUidKey = checkBoxAutoLoadKey.Checked; @@ -1303,5 +1360,10 @@ namespace MifareOneTool { Properties.Settings.Default.AutoSave = checkBoxAutoSave.Checked; } + + private void checkBoxHardLowCost_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.HardLowCost = checkBoxHardLowCost.Checked; + } } } diff --git a/MifareOneTool/Form1.resx b/MifareOneTool/Form1.resx index 1215db1..b3a5c75 100644 --- a/MifareOneTool/Form1.resx +++ b/MifareOneTool/Form1.resx @@ -120,9 +120,6 @@ 17, 17 - - 17, 17 - 157, 17 diff --git a/MifareOneTool/FormHTool.Designer.cs b/MifareOneTool/FormHTool.Designer.cs index 83fe662..cd111b2 100644 --- a/MifareOneTool/FormHTool.Designer.cs +++ b/MifareOneTool/FormHTool.Designer.cs @@ -43,8 +43,11 @@ 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.导出为MCT格式ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.导出密钥字典ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + 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(); @@ -72,9 +75,6 @@ this.groupBox3 = new System.Windows.Forms.GroupBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.s50BindingSource = new System.Windows.Forms.BindingSource(this.components); - this.导入MCT格式ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.列出全卡密钥ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); @@ -204,6 +204,14 @@ 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.L))); + 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); + // // 导出为MCT格式ToolStripMenuItem // this.导出为MCT格式ToolStripMenuItem.Name = "导出为MCT格式ToolStripMenuItem"; @@ -220,6 +228,19 @@ this.导出密钥字典ToolStripMenuItem.Text = "导出密钥字典"; this.导出密钥字典ToolStripMenuItem.Click += new System.EventHandler(this.导出密钥字典ToolStripMenuItem_Click); // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.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.I))); + 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); @@ -534,27 +555,6 @@ // this.s50BindingSource.DataSource = typeof(MifareOneTool.S50); // - // 导入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.L))); - 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); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.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.I))); - 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; @@ -570,6 +570,7 @@ this.MaximizeBox = false; this.Name = "FormHTool"; this.Text = "S50HTool-beta"; + this.Load += new System.EventHandler(this.FormHTool_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.groupBox1.ResumeLayout(false); diff --git a/MifareOneTool/FormHTool.cs b/MifareOneTool/FormHTool.cs index 90431dc..3270f9b 100644 --- a/MifareOneTool/FormHTool.cs +++ b/MifareOneTool/FormHTool.cs @@ -250,7 +250,9 @@ namespace MifareOneTool list3.AddRange(kC); list3.AddRange(kB); byte[] block3 = list3.Take(16).ToArray(); + byte lastUC=currentS50.Sectors[currentSector].Block[3][9]; currentS50.Sectors[currentSector].Block[3] = block3; + currentS50.Sectors[currentSector].Block[3][9] = lastUC; for (int i = 0; i < 16; i++) { dataGridView1.Rows[i].Cells[0].Value = currentS50.Sectors[i].Info(i); @@ -482,5 +484,10 @@ namespace MifareOneTool richTextBox1.Clear(); richTextBox1.Text = sb.ToString(); } + + private void FormHTool_Load(object sender, EventArgs e) + { + 新建ToolStripMenuItem_Click(sender, e); + } } } 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/FormHardNes.Designer.cs b/MifareOneTool/FormHardNes.Designer.cs index f560829..1491d2f 100644 --- a/MifareOneTool/FormHardNes.Designer.cs +++ b/MifareOneTool/FormHardNes.Designer.cs @@ -31,20 +31,21 @@ this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.keyEdit = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.radioKey1A = new System.Windows.Forms.RadioButton(); this.radioKey1B = new System.Windows.Forms.RadioButton(); + this.radioKey1A = new System.Windows.Forms.RadioButton(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.sector1 = new System.Windows.Forms.TextBox(); + this.keyEdit = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); this.radioKey2B = new System.Windows.Forms.RadioButton(); this.radioKey2A = new System.Windows.Forms.RadioButton(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.sector2 = new System.Windows.Forms.TextBox(); - this.sector1 = new System.Windows.Forms.TextBox(); + this.checkBoxColOnly = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); @@ -86,50 +87,15 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "目标卡信息"; // - // label1 + // radioKey1B // - this.label1.AutoSize = true; - this.label1.ForeColor = System.Drawing.Color.Blue; - this.label1.Location = new System.Drawing.Point(12, 192); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(202, 15); - this.label1.TabIndex = 3; - this.label1.Text = "解密时请保证设备良好散热!"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 21); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(76, 15); - this.label2.TabIndex = 0; - this.label2.Text = "已知的Key"; - // - // keyEdit - // - this.keyEdit.Location = new System.Drawing.Point(9, 39); - this.keyEdit.Name = "keyEdit"; - this.keyEdit.Size = new System.Drawing.Size(120, 25); - this.keyEdit.TabIndex = 10; - this.keyEdit.Text = "ffffffffffff"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(132, 21); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(52, 15); - this.label3.TabIndex = 12; - this.label3.Text = "扇区号"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(190, 21); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(37, 15); - this.label4.TabIndex = 13; - this.label4.Text = "类型"; + this.radioKey1B.AutoSize = true; + this.radioKey1B.Location = new System.Drawing.Point(259, 40); + this.radioKey1B.Name = "radioKey1B"; + this.radioKey1B.Size = new System.Drawing.Size(60, 19); + this.radioKey1B.TabIndex = 15; + this.radioKey1B.Text = "KeyB"; + this.radioKey1B.UseVisualStyleBackColor = true; // // radioKey1A // @@ -143,15 +109,58 @@ this.radioKey1A.Text = "KeyA"; this.radioKey1A.UseVisualStyleBackColor = true; // - // radioKey1B + // label4 // - this.radioKey1B.AutoSize = true; - this.radioKey1B.Location = new System.Drawing.Point(259, 40); - this.radioKey1B.Name = "radioKey1B"; - this.radioKey1B.Size = new System.Drawing.Size(60, 19); - this.radioKey1B.TabIndex = 15; - this.radioKey1B.Text = "KeyB"; - this.radioKey1B.UseVisualStyleBackColor = true; + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(190, 21); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(37, 15); + this.label4.TabIndex = 13; + this.label4.Text = "类型"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(132, 21); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(52, 15); + this.label3.TabIndex = 12; + this.label3.Text = "扇区号"; + // + // sector1 + // + this.sector1.Location = new System.Drawing.Point(135, 39); + this.sector1.Name = "sector1"; + this.sector1.Size = new System.Drawing.Size(46, 25); + this.sector1.TabIndex = 11; + this.sector1.Text = "0"; + // + // keyEdit + // + this.keyEdit.Location = new System.Drawing.Point(9, 39); + this.keyEdit.Name = "keyEdit"; + this.keyEdit.Size = new System.Drawing.Size(120, 25); + this.keyEdit.TabIndex = 10; + this.keyEdit.Text = "ffffffffffff"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 21); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(76, 15); + this.label2.TabIndex = 0; + this.label2.Text = "已知的Key"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.ForeColor = System.Drawing.Color.Blue; + this.label1.Location = new System.Drawing.Point(12, 192); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(202, 15); + this.label1.TabIndex = 3; + this.label1.Text = "解密时请保证设备良好散热!"; // // radioKey2B // @@ -195,6 +204,7 @@ // // groupBox2 // + this.groupBox2.Controls.Add(this.checkBoxColOnly); this.groupBox2.Controls.Add(this.radioKey2B); this.groupBox2.Controls.Add(this.radioKey2A); this.groupBox2.Controls.Add(this.label5); @@ -215,13 +225,15 @@ this.sector2.TabIndex = 11; this.sector2.Text = "1"; // - // sector1 + // checkBoxColOnly // - this.sector1.Location = new System.Drawing.Point(135, 39); - this.sector1.Name = "sector1"; - this.sector1.Size = new System.Drawing.Size(46, 25); - this.sector1.TabIndex = 11; - this.sector1.Text = "0"; + this.checkBoxColOnly.AutoSize = true; + this.checkBoxColOnly.Location = new System.Drawing.Point(9, 39); + this.checkBoxColOnly.Name = "checkBoxColOnly"; + this.checkBoxColOnly.Size = new System.Drawing.Size(119, 19); + this.checkBoxColOnly.TabIndex = 17; + this.checkBoxColOnly.Text = "只采集不计算"; + this.checkBoxColOnly.UseVisualStyleBackColor = true; // // FormHardNes // @@ -269,5 +281,6 @@ private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TextBox sector2; private System.Windows.Forms.TextBox sector1; + private System.Windows.Forms.CheckBox checkBoxColOnly; } } \ No newline at end of file diff --git a/MifareOneTool/FormHardNes.cs b/MifareOneTool/FormHardNes.cs index bd5fc0e..2b89dfa 100644 --- a/MifareOneTool/FormHardNes.cs +++ b/MifareOneTool/FormHardNes.cs @@ -22,11 +22,11 @@ namespace MifareOneTool int trailer_block = 0; if (sector < 32) { - trailer_block = sector*4 + 3; + trailer_block = sector * 4 + 3; } else { - trailer_block = 128+16*(sector-32) + 15; + trailer_block = 128 + 16 * (sector - 32) + 15; } return trailer_block; } @@ -36,12 +36,26 @@ namespace MifareOneTool string arg = ""; arg += keyEdit.Text.ToUpper() + " "; arg += getBlock(Convert.ToInt32(sector1.Text.Trim())).ToString() + " "; - arg += (radioKey1A.Checked ?"A":"B") + " "; + arg += (radioKey1A.Checked ? "A" : "B") + " "; arg += getBlock(Convert.ToInt32(sector2.Text.Trim())).ToString() + " "; arg += radioKey2A.Checked ? "A" : "B"; return arg; } + public string GetFileAfter() + { + string a = "_"; + a += string.Format("{0:D3}", getBlock(Convert.ToInt32(sector2.Text.Trim()))); + a += radioKey2A.Checked ? "A" : "B"; + a += ".txt"; + return a; + } + + public bool collectOnly() + { + return checkBoxColOnly.Checked; + } + private void button2_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; diff --git a/MifareOneTool/Program.cs b/MifareOneTool/Program.cs index 4dae145..cb67eac 100644 --- a/MifareOneTool/Program.cs +++ b/MifareOneTool/Program.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Windows.Forms; +using System.Diagnostics; +using System.Reflection; namespace MifareOneTool { @@ -13,9 +15,29 @@ namespace MifareOneTool [STAThread] static void Main() { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); + bool ret; + System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out ret); + if (ret) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + mutex.ReleaseMutex(); + } + else + { + if (MessageBox.Show("您已经运行了MifareOne Tool,打开多个本程序可能会造成冲突及不可预料到的错误。\n确认要继续吗?", "您正在试图重复运行", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + mutex.ReleaseMutex(); + } + else + { + Application.Exit(); + } + } } } } diff --git a/MifareOneTool/Properties/AssemblyInfo.cs b/MifareOneTool/Properties/AssemblyInfo.cs index e37fa4f..573e556 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.6.4.0")] -[assembly: AssemblyFileVersion("1.6.4.0")] +[assembly: AssemblyVersion("1.6.5.0")] +[assembly: AssemblyFileVersion("1.6.5.0")] diff --git a/MifareOneTool/Properties/Settings.Designer.cs b/MifareOneTool/Properties/Settings.Designer.cs index fbdb891..617758d 100644 --- a/MifareOneTool/Properties/Settings.Designer.cs +++ b/MifareOneTool/Properties/Settings.Designer.cs @@ -115,5 +115,17 @@ namespace MifareOneTool.Properties { this["AutoSave"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool HardLowCost { + get { + return ((bool)(this["HardLowCost"])); + } + set { + this["HardLowCost"] = value; + } + } } } diff --git a/MifareOneTool/Properties/Settings.settings b/MifareOneTool/Properties/Settings.settings index aab9dcd..2c10aab 100644 --- a/MifareOneTool/Properties/Settings.settings +++ b/MifareOneTool/Properties/Settings.settings @@ -26,5 +26,8 @@ False + + False + \ No newline at end of file diff --git a/MifareOneTool/app.config b/MifareOneTool/app.config index 43fd3e8..3943de3 100644 --- a/MifareOneTool/app.config +++ b/MifareOneTool/app.config @@ -38,6 +38,9 @@ False + + False + \ No newline at end of file