Added SetUID

This commit is contained in:
XAS-712 2018-12-22 18:43:16 +08:00
parent cff0deb59e
commit b245028f85
2 changed files with 66 additions and 49 deletions

View File

@ -30,7 +30,6 @@
{ {
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button12 = new System.Windows.Forms.Button(); this.button12 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.richTextBox1 = new System.Windows.Forms.RichTextBox();
@ -45,9 +44,9 @@
this.button5 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button13 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button15 = new System.Windows.Forms.Button(); this.button15 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
@ -56,7 +55,6 @@
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.button12); this.groupBox1.Controls.Add(this.button12);
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1); this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Location = new System.Drawing.Point(12, 12);
@ -68,31 +66,19 @@
// //
// button12 // button12
// //
this.button12.Location = new System.Drawing.Point(87, 24); this.button12.Location = new System.Drawing.Point(102, 24);
this.button12.Name = "button12"; this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(75, 23); this.button12.Size = new System.Drawing.Size(90, 23);
this.button12.TabIndex = 11; this.button12.TabIndex = 11;
this.button12.Text = "手动CLI"; this.button12.Text = "手动CLI";
this.button12.UseVisualStyleBackColor = true; this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.button12_Click); this.button12.Click += new System.EventHandler(this.button12_Click);
// //
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Enabled = false;
this.checkBox1.Location = new System.Drawing.Point(87, 56);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(89, 19);
this.checkBox1.TabIndex = 2;
this.checkBox1.Text = "自动扫描";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// button2 // button2
// //
this.button2.Location = new System.Drawing.Point(6, 53); this.button2.Location = new System.Drawing.Point(6, 53);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23); this.button2.Size = new System.Drawing.Size(90, 23);
this.button2.TabIndex = 1; this.button2.TabIndex = 1;
this.button2.Text = "手动扫描"; this.button2.Text = "手动扫描";
this.button2.UseVisualStyleBackColor = true; this.button2.UseVisualStyleBackColor = true;
@ -102,7 +88,7 @@
// //
this.button1.Location = new System.Drawing.Point(6, 24); this.button1.Location = new System.Drawing.Point(6, 24);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Size = new System.Drawing.Size(90, 23);
this.button1.TabIndex = 0; this.button1.TabIndex = 0;
this.button1.Text = "检测"; this.button1.Text = "检测";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
@ -179,13 +165,13 @@
// //
// button8 // button8
// //
this.button8.Enabled = false;
this.button8.Location = new System.Drawing.Point(168, 53); this.button8.Location = new System.Drawing.Point(168, 53);
this.button8.Name = "button8"; this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(75, 23); this.button8.Size = new System.Drawing.Size(75, 23);
this.button8.TabIndex = 5; this.button8.TabIndex = 5;
this.button8.Text = "UID写号"; this.button8.Text = "UID写号";
this.button8.UseVisualStyleBackColor = true; this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click);
// //
// button7 // button7
// //
@ -239,15 +225,15 @@
this.groupBox3.TabStop = false; this.groupBox3.TabStop = false;
this.groupBox3.Text = "运行/终端"; this.groupBox3.Text = "运行/终端";
// //
// button13 // button15
// //
this.button13.Location = new System.Drawing.Point(6, 24); this.button15.Location = new System.Drawing.Point(6, 53);
this.button13.Name = "button13"; this.button15.Name = "button15";
this.button13.Size = new System.Drawing.Size(75, 23); this.button15.Size = new System.Drawing.Size(75, 23);
this.button13.TabIndex = 0; this.button15.TabIndex = 2;
this.button13.Text = "清空终端"; this.button15.Text = "停止运行";
this.button13.UseVisualStyleBackColor = true; this.button15.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.button13_Click); this.button15.Click += new System.EventHandler(this.button15_Click);
// //
// button14 // button14
// //
@ -259,15 +245,15 @@
this.button14.UseVisualStyleBackColor = true; this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.button14_Click); this.button14.Click += new System.EventHandler(this.button14_Click);
// //
// button15 // button13
// //
this.button15.Location = new System.Drawing.Point(6, 53); this.button13.Location = new System.Drawing.Point(6, 24);
this.button15.Name = "button15"; this.button13.Name = "button13";
this.button15.Size = new System.Drawing.Size(75, 23); this.button13.Size = new System.Drawing.Size(75, 23);
this.button15.TabIndex = 2; this.button13.TabIndex = 0;
this.button15.Text = "停止运行"; this.button13.Text = "清空终端";
this.button15.UseVisualStyleBackColor = true; this.button13.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.button15_Click); this.button13.Click += new System.EventHandler(this.button13_Click);
// //
// Form1 // Form1
// //
@ -284,7 +270,6 @@
this.Text = "MifareOne Tool"; this.Text = "MifareOne Tool";
this.Load += new System.EventHandler(this.Form1_Load); this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false); this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false); this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false); this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -294,7 +279,6 @@
#endregion #endregion
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.RichTextBox richTextBox1;

View File

@ -9,6 +9,8 @@ using System.Windows.Forms;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
namespace MifareOneTool namespace MifareOneTool
{ {
@ -22,16 +24,6 @@ namespace MifareOneTool
private Process process = new Process(); private Process process = new Process();
private bool lprocess = false; private bool lprocess = false;
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
button2.Enabled = false;
}else{
button2.Enabled = true;
}
}
private void lockBtn(bool locks) private void lockBtn(bool locks)
{ {
//if (locks) //if (locks)
@ -500,5 +492,46 @@ namespace MifareOneTool
{ {
process.Kill(); process.Kill();
} }
private void button8_Click(object sender, EventArgs e)
{
string pat = "[0-9A-Fa-f]{8}";
if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; }
byte[] buid = new byte[4];
RNGCryptoServiceProvider rng=new RNGCryptoServiceProvider();
rng.GetNonZeroBytes(buid);
string uid = Interaction.InputBox("请输入UID号", "请输入需要写入的UID卡号共8位十六进制数如E44A3BF1。", hex(buid),-1,-1).Trim();
if(!Regex.IsMatch(uid, pat)){
MessageBox.Show("输入的UID号不合法", "InputError", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
BackgroundWorker bgw = new BackgroundWorker();
bgw.DoWork += new DoWorkEventHandler(set_uid);
bgw.WorkerReportsProgress = true;
bgw.ProgressChanged += new ProgressChangedEventHandler(default_rpt);
bgw.RunWorkerAsync();
}
void set_uid(object sender, DoWorkEventArgs e)
{
if (lprocess) { return; }
ProcessStartInfo psi = new ProcessStartInfo("nfc-bin/nfc-mfsetuid.exe");
psi.Arguments = "" + ((string)e.Argument).Substring(0,8) + "2B0804006263646566676869";
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
lprocess = true;
BackgroundWorker b = (BackgroundWorker)sender;
process = Process.Start(psi);
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;
b.ReportProgress(100, "##运行完毕##");
}
} }
} }