This commit is contained in:
XAS-712 2019-01-24 14:36:46 +08:00
parent 91d2bdb68a
commit 2ae5a98a68
13 changed files with 235 additions and 98 deletions

2
.gitignore vendored
View File

@ -330,4 +330,4 @@ ASALocalRun/
.mfractor/
nfc-bin.zip
Setup1/
DirectOP/

View File

@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MifareOneTool", "MifareOneTool\MifareOneTool.csproj", "{CDB26016-FC77-403F-B22A-A011F8622FCF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectOP", "DirectOP\DirectOP.vcxproj", "{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -27,6 +29,18 @@ Global
{CDB26016-FC77-403F-B22A-A011F8622FCF}.Release|Win32.ActiveCfg = Release|x86
{CDB26016-FC77-403F-B22A-A011F8622FCF}.Release|x86.ActiveCfg = Release|x86
{CDB26016-FC77-403F-B22A-A011F8622FCF}.Release|x86.Build.0 = Release|x86
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Debug|Win32.ActiveCfg = Debug|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Debug|Win32.Build.0 = Debug|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Debug|x86.ActiveCfg = Debug|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Release|Any CPU.ActiveCfg = Release|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Release|Mixed Platforms.Build.0 = Release|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Release|Win32.ActiveCfg = Release|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Release|Win32.Build.0 = Release|Win32
{E17E8EAB-394B-4907-97CB-7CDFF40B3F78}.Release|x86.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MifareOneTool
{
class ClassMfClassic
{
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
using System.Text.RegularExpressions;
namespace MifareOneTool
{
@ -18,7 +19,7 @@ namespace MifareOneTool
}
return ret.ToString();
}
public static string Hex2StrS(byte[] bytes)
public static string Hex2StrWithSpan(byte[] bytes)
{
StringBuilder ret = new StringBuilder();
foreach (byte b in bytes)
@ -28,6 +29,14 @@ namespace MifareOneTool
}
return ret.ToString();
}
public static byte[] Hex2Block(string hex, int bytelen)
{
hex = hex.Replace(" ", "");
byte[] returnBytes = new byte[bytelen];
for (int i = 0; i < bytelen; i++)
returnBytes[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
return returnBytes;
}
public static byte[] ReadAC(byte[] ac)
{
byte[] acbits = new byte[4];
@ -101,6 +110,23 @@ namespace MifareOneTool
| ((ac[3] << 6) & 0x80));
return acbits;
}
//public static bool DtKeyAB(byte[] ac)
//{
// byte[] acbits = new byte[4];
// acbits[0] = (byte)(((ac[2] & 0x10) >> 4)
// + ((ac[2] & 0x01) << 1)
// + ((ac[1] & 0x10) >> 2));
// acbits[1] = (byte)(((ac[2] & 0x20) >> 5)
// + ((ac[2] & 0x02))
// + ((ac[1] & 0x20) >> 3));
// acbits[2] = (byte)(((ac[2] & 0x40) >> 6)
// + ((ac[2] & 0x04) >> 1)
// + ((ac[1] & 0x40) >> 4));
// acbits[3] = (byte)(((ac[2] & 0x80) >> 7)
// + ((ac[2] & 0x08) >> 2)
// + ((ac[1] & 0x80) >> 5));
// return acbits;
//}
}
enum AccessBitsT
{
@ -170,7 +196,7 @@ namespace MifareOneTool
}
public Sector(byte[] uid)
{
if(uid.Length!=4){throw new Exception("不恰当的4字节UID长度");}
if (uid.Length != 4) { throw new Exception("不恰当的4字节UID长度"); }
this._isSector0 = true;
this.Wipe();
byte bcc = (byte)(uid[0] ^ uid[1] ^ uid[2] ^ uid[3]);
@ -192,13 +218,13 @@ namespace MifareOneTool
int retCode = 0;
if (this._isSector0)
{
byte bc0 = (byte)(_sector[0][0]^_sector[0][1]^_sector[0][2]^_sector[0][3]^_sector[0][4]);
byte bc0 = (byte)(_sector[0][0] ^ _sector[0][1] ^ _sector[0][2] ^ _sector[0][3] ^ _sector[0][4]);
if (bc0 != 0x00) { retCode = retCode | 0x01; }
}
byte[] ac=new byte[4]{_sector[3][6],_sector[3][7],_sector[3][8],_sector[3][9]};
byte[] ac = new byte[4] { _sector[3][6], _sector[3][7], _sector[3][8], _sector[3][9] };
byte[] acP = Utils.ReadAC(ac);
byte[] acN = Utils.ReadRAC(ac);
if (!Enumerable.SequenceEqual(acP,acN))
if (!Enumerable.SequenceEqual(acP, acN))
{
retCode = retCode | 0x04;
}
@ -259,7 +285,8 @@ namespace MifareOneTool
internal byte[] SectorsRaw
{
get {
get
{
byte[] buffer = new byte[1024];
for (int i = 0; i < 16; i++)
{
@ -344,6 +371,33 @@ namespace MifareOneTool
this.Wipe();
this.SectorsRaw = (byte[])loadByte;
}
public void LoadFromMctTxt(string file)
{
if (!File.Exists(file)) { throw new IOException("加载的文件不存在。"); }
if (new FileInfo(file).Length < 2300 || new FileInfo(file).Length > 2400) { throw new IOException("加载的S50卡文件大小异常。"); }
List<string> lines = new List<string>(File.ReadAllLines(file));
List<string> invaild = new List<string>();
foreach (string line in lines)
{
if (!Regex.IsMatch(line, "[0-9A-Fa-f]{32}") || line.Length != 32)
{
invaild.Add(line);
}
}
foreach (string inv in invaild)
{
lines.Remove(inv);
}
if (lines.Count != 64)
{
throw new Exception("文件内不是含有64个块数据可能不完整或不兼容。");
}
this.Wipe();
for (int i = 0; i < lines.Count; i++)
{
this._sectors[i / 4].Block[i % 4] = Utils.Hex2Block(lines[i], 16);
}
}
public void ExportToMfd(string file)
{
byte[] fileBuffer = this.SectorsRaw;

View File

@ -32,7 +32,6 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.groupBox1 = new System.Windows.Forms.GroupBox();
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();
@ -79,6 +78,8 @@
this.buttonEMfoc = new System.Windows.Forms.Button();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.buttonDictMfoc = new System.Windows.Forms.Button();
this.buttonnKeysMfoc = new System.Windows.Forms.Button();
this.buttonHardNested = new System.Windows.Forms.Button();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
@ -90,8 +91,7 @@
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.buttonSniffDev = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -110,8 +110,8 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.buttonSniffDev);
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);
@ -129,20 +129,10 @@
this.buttonCLI.Size = new System.Drawing.Size(90, 23);
this.buttonCLI.TabIndex = 11;
this.buttonCLI.Text = "手动CLI";
this.toolTipHelp.SetToolTip(this.buttonCLI, "打开NFC命令行以进行高级操作。");
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);
@ -151,6 +141,7 @@
this.buttonScanCard.Size = new System.Drawing.Size(90, 23);
this.buttonScanCard.TabIndex = 1;
this.buttonScanCard.Text = "手动扫描";
this.toolTipHelp.SetToolTip(this.buttonScanCard, "扫描有效卡片。");
this.buttonScanCard.UseVisualStyleBackColor = true;
this.buttonScanCard.Click += new System.EventHandler(this.buttonScanCard_Click);
//
@ -162,6 +153,7 @@
this.buttonListDev.Size = new System.Drawing.Size(90, 23);
this.buttonListDev.TabIndex = 0;
this.buttonListDev.Text = "检测设备";
this.toolTipHelp.SetToolTip(this.buttonListDev, "扫描已连接的NFC设备\r\n(目前支持PN532、ACR122U)");
this.buttonListDev.UseVisualStyleBackColor = true;
this.buttonListDev.Click += new System.EventHandler(this.buttonListDev_Click);
//
@ -172,7 +164,7 @@
this.richTextBox1.Location = new System.Drawing.Point(0, 219);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(767, 300);
this.richTextBox1.Size = new System.Drawing.Size(767, 381);
this.richTextBox1.TabIndex = 1;
this.richTextBox1.Text = "Hello,cardman!\n建议点击\"检测\"以加快后续运行速度\n";
//
@ -184,6 +176,7 @@
this.buttonMfRead.Size = new System.Drawing.Size(50, 23);
this.buttonMfRead.TabIndex = 3;
this.buttonMfRead.Text = "读M1";
this.toolTipHelp.SetToolTip(this.buttonMfRead, "读取普通M1卡片可能需要加载密钥文件");
this.buttonMfRead.UseVisualStyleBackColor = true;
this.buttonMfRead.Click += new System.EventHandler(this.buttonMfRead_Click);
//
@ -208,6 +201,7 @@
this.buttonMfFormat.Size = new System.Drawing.Size(50, 23);
this.buttonMfFormat.TabIndex = 6;
this.buttonMfFormat.Text = "清M1";
this.toolTipHelp.SetToolTip(this.buttonMfFormat, "格式化普通M1卡必须加载密钥文件");
this.buttonMfFormat.UseVisualStyleBackColor = true;
this.buttonMfFormat.Click += new System.EventHandler(this.buttonMfFormat_Click);
//
@ -219,6 +213,7 @@
this.buttonMfWrite.Size = new System.Drawing.Size(50, 23);
this.buttonMfWrite.TabIndex = 5;
this.buttonMfWrite.Text = "写M1";
this.toolTipHelp.SetToolTip(this.buttonMfWrite, "写入普通M1卡可能需要加载密钥文件");
this.buttonMfWrite.UseVisualStyleBackColor = true;
this.buttonMfWrite.Click += new System.EventHandler(this.buttonMfWrite_Click);
//
@ -230,6 +225,7 @@
this.buttonSelectKey.Size = new System.Drawing.Size(156, 23);
this.buttonSelectKey.TabIndex = 4;
this.buttonSelectKey.Text = "选择key.mfd";
this.toolTipHelp.SetToolTip(this.buttonSelectKey, "加载含有正确读写卡密钥及正确控制位的MFD文件。");
this.buttonSelectKey.UseVisualStyleBackColor = true;
this.buttonSelectKey.Click += new System.EventHandler(this.buttonSelectKey_Click);
//
@ -241,6 +237,7 @@
this.buttonBmfWrite.Size = new System.Drawing.Size(75, 23);
this.buttonBmfWrite.TabIndex = 10;
this.buttonBmfWrite.Text = "UID写";
this.toolTipHelp.SetToolTip(this.buttonBmfWrite, "写入UID卡片。");
this.buttonBmfWrite.UseVisualStyleBackColor = true;
this.buttonBmfWrite.Click += new System.EventHandler(this.buttonBmfWrite_Click);
//
@ -252,6 +249,7 @@
this.buttonBmfRead.Size = new System.Drawing.Size(75, 23);
this.buttonBmfRead.TabIndex = 9;
this.buttonBmfRead.Text = "UID读";
this.toolTipHelp.SetToolTip(this.buttonBmfRead, "读取UID卡片。");
this.buttonBmfRead.UseVisualStyleBackColor = true;
this.buttonBmfRead.Click += new System.EventHandler(this.buttonBmfRead_Click);
//
@ -263,7 +261,7 @@
this.buttonMfoc.Size = new System.Drawing.Size(75, 23);
this.buttonMfoc.TabIndex = 8;
this.buttonMfoc.Text = "MFOC读";
this.toolTipHelp.SetToolTip(this.buttonMfoc, "按住Ctrl点击该按钮可添加已知密钥。");
this.toolTipHelp.SetToolTip(this.buttonMfoc, "对半加密卡片进行Nested破解。\r\n按住Ctrl点击该按钮可添加已知密钥。");
this.buttonMfoc.UseVisualStyleBackColor = true;
this.buttonMfoc.Click += new System.EventHandler(this.buttonMfoc_Click);
//
@ -275,6 +273,7 @@
this.buttonUidWrite.Size = new System.Drawing.Size(75, 23);
this.buttonUidWrite.TabIndex = 5;
this.buttonUidWrite.Text = "UID写号";
this.toolTipHelp.SetToolTip(this.buttonUidWrite, "向UID卡片写入置顶卡号厂商设置为复旦。");
this.buttonUidWrite.UseVisualStyleBackColor = true;
this.buttonUidWrite.Click += new System.EventHandler(this.buttonUidWrite_Click);
//
@ -286,6 +285,7 @@
this.buttonUidFormat.Size = new System.Drawing.Size(75, 23);
this.buttonUidFormat.TabIndex = 7;
this.buttonUidFormat.Text = "UID全格";
this.toolTipHelp.SetToolTip(this.buttonUidFormat, "将全卡清空并重新初始化。\r\n可用于ACbit损坏/KEY全部被改等情况的急救。");
this.buttonUidFormat.UseVisualStyleBackColor = true;
this.buttonUidFormat.Click += new System.EventHandler(this.buttonUidFormat_Click);
//
@ -297,6 +297,7 @@
this.buttonUidReset.Size = new System.Drawing.Size(75, 23);
this.buttonUidReset.TabIndex = 6;
this.buttonUidReset.Text = "UID重置";
this.toolTipHelp.SetToolTip(this.buttonUidReset, "重置UID卡片0块UID随机厂商号为复旦。");
this.buttonUidReset.UseVisualStyleBackColor = true;
this.buttonUidReset.Click += new System.EventHandler(this.buttonUidReset_Click);
//
@ -353,6 +354,7 @@
this.buttonMfcuk.Size = new System.Drawing.Size(104, 22);
this.buttonMfcuk.TabIndex = 3;
this.buttonMfcuk.Text = "全加密爆破";
this.toolTipHelp.SetToolTip(this.buttonMfcuk, "对卡片执行Darkside工具不一定成功");
this.buttonMfcuk.UseVisualStyleBackColor = true;
this.buttonMfcuk.Click += new System.EventHandler(this.buttonMfcuk_Click);
//
@ -382,7 +384,7 @@
//
this.toolTipHelp.AutoPopDelay = 2000;
this.toolTipHelp.InitialDelay = 500;
this.toolTipHelp.ReshowDelay = 100;
this.toolTipHelp.ReshowDelay = 1000;
this.toolTipHelp.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
this.toolTipHelp.ToolTipTitle = "提示";
//
@ -405,6 +407,7 @@
this.buttonCheckEncrypt.Size = new System.Drawing.Size(75, 23);
this.buttonCheckEncrypt.TabIndex = 13;
this.buttonCheckEncrypt.Text = "检加密";
this.toolTipHelp.SetToolTip(this.buttonCheckEncrypt, "检测卡片加密情况。");
this.buttonCheckEncrypt.UseVisualStyleBackColor = true;
this.buttonCheckEncrypt.Click += new System.EventHandler(this.buttonCheckEncrypt_Click);
//
@ -416,6 +419,7 @@
this.buttonLockUfuid.Size = new System.Drawing.Size(75, 23);
this.buttonLockUfuid.TabIndex = 5;
this.buttonLockUfuid.Text = "锁Ufuid";
this.toolTipHelp.SetToolTip(this.buttonLockUfuid, "锁死UFUID卡片0块数据测试中");
this.buttonLockUfuid.UseVisualStyleBackColor = true;
this.buttonLockUfuid.Click += new System.EventHandler(this.buttonLockUfuid_Click);
//
@ -427,6 +431,7 @@
this.buttonCmfWrite.Size = new System.Drawing.Size(75, 23);
this.buttonCmfWrite.TabIndex = 4;
this.buttonCmfWrite.Text = "CUID写";
this.toolTipHelp.SetToolTip(this.buttonCmfWrite, "写入CUID/FUID卡片可能需要密钥文件");
this.buttonCmfWrite.UseVisualStyleBackColor = true;
this.buttonCmfWrite.Click += new System.EventHandler(this.buttonCmfWrite_Click);
//
@ -654,6 +659,28 @@
this.groupBox10.TabStop = false;
this.groupBox10.Text = "破解工具";
//
// 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.toolTipHelp.SetToolTip(this.buttonDictMfoc, "导入字典文件进行Nested破解。");
this.buttonDictMfoc.UseVisualStyleBackColor = true;
this.buttonDictMfoc.Click += new System.EventHandler(this.buttonDictMfoc_Click);
//
// 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.toolTipHelp.SetToolTip(this.buttonnKeysMfoc, "输入已知密钥进行Nested破解。");
this.buttonnKeysMfoc.UseVisualStyleBackColor = true;
this.buttonnKeysMfoc.Click += new System.EventHandler(this.buttonnKeysMfoc_Click);
//
// buttonHardNested
//
this.buttonHardNested.Enabled = false;
@ -708,7 +735,7 @@
this.localVersionLabel,
this.remoteVersionLabel,
this.toolStripCheckUpdate});
this.statusStrip1.Location = new System.Drawing.Point(0, 522);
this.statusStrip1.Location = new System.Drawing.Point(0, 603);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(767, 26);
this.statusStrip1.TabIndex = 12;
@ -757,31 +784,21 @@
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// buttonnKeysMfoc
// buttonSniffDev
//
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);
this.buttonSniffDev.Enabled = false;
this.buttonSniffDev.Location = new System.Drawing.Point(102, 52);
this.buttonSniffDev.Name = "buttonSniffDev";
this.buttonSniffDev.Size = new System.Drawing.Size(90, 23);
this.buttonSniffDev.TabIndex = 12;
this.buttonSniffDev.Text = "联机嗅探";
this.buttonSniffDev.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(767, 548);
this.ClientSize = new System.Drawing.Size(767, 629);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.richTextBox1);
@ -858,7 +875,6 @@
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button buttonEMfWrite;
private System.Windows.Forms.Button buttonEAdv;
private System.Windows.Forms.Button buttonEnAcr122u;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel statusLabel;
private System.Windows.Forms.ToolStripStatusLabel runTimeLabel;
@ -875,6 +891,7 @@
private System.Windows.Forms.ToolStripSplitButton toolStripCheckUpdate;
private System.Windows.Forms.Button buttonDictMfoc;
private System.Windows.Forms.Button buttonnKeysMfoc;
private System.Windows.Forms.Button buttonSniffDev;
}
}

View File

@ -760,7 +760,7 @@ namespace MifareOneTool
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";
string kt = "c";
switch (MessageBox.Show("使用KeyA或KeyB", "KeyA/B", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
{
case DialogResult.No:
@ -1000,11 +1000,11 @@ namespace MifareOneTool
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 cmd_mode="/k";
//if (Control.ModifierKeys == Keys.Control)
//{
// cmd_mode="/k";
//}
string filename = "";
OpenFileDialog ofd = new OpenFileDialog();
ofd.CheckFileExists = true;

View File

@ -120,9 +120,6 @@
<metadata name="toolTipHelp.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTipHelp.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>157, 17</value>
</metadata>

View File

@ -118,8 +118,8 @@ namespace MifareOneTool
res+="## ";
}
}
stb.AppendLine("A: " + Utils.Hex2StrS(sa.Sectors[i].Block[a]));
stb.AppendLine("B: " + Utils.Hex2StrS(sb.Sectors[i].Block[a]));
stb.AppendLine("A: " + Utils.Hex2StrWithSpan(sa.Sectors[i].Block[a]));
stb.AppendLine("B: " + Utils.Hex2StrWithSpan(sb.Sectors[i].Block[a]));
stb.AppendLine(" " + res);
}

View File

@ -71,8 +71,10 @@
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.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();
@ -159,9 +161,11 @@
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.toolStripSeparator3,
this.MCT格式ToolStripMenuItem,
this.MCT格式ToolStripMenuItem,
this.ToolStripMenuItem,
this.toolStripMenuItem1});
this.toolStripSeparator4,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "工具ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(51, 24);
this.ToolStripMenuItem.Text = "工具";
@ -526,18 +530,31 @@
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);
//
// 导入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;
@ -612,5 +629,8 @@
private System.Windows.Forms.ToolStripMenuItem MCT格式ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem MCT格式ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
}
}

View File

@ -221,15 +221,6 @@ namespace MifareOneTool
}
}
private static byte[] Hex2Block(string hex,int bytelen)
{
hex = hex.Replace(" ", "");
byte[] returnBytes = new byte[bytelen];
for (int i = 0; i < bytelen; i++)
returnBytes[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
return returnBytes;
}
private void buttonSaveSectorEdit_Click(object sender, EventArgs e)
{
if (currentSector >= 0 && currentSector <= 15)
@ -244,11 +235,11 @@ namespace MifareOneTool
MessageBox.Show("当前扇区数据仍有错误,不能执行修改。");
return;
}
currentS50.Sectors[currentSector].Block[0] = Hex2Block(block0Edit.Text.Trim(),16);
currentS50.Sectors[currentSector].Block[1] = Hex2Block(block1Edit.Text.Trim(), 16);
currentS50.Sectors[currentSector].Block[2] = Hex2Block(block2Edit.Text.Trim(), 16);
byte[] kA = Hex2Block(keyAEdit.Text.Trim(), 6);
byte[] kB = Hex2Block(keyBEdit.Text.Trim(), 6);
currentS50.Sectors[currentSector].Block[0] = Utils.Hex2Block(block0Edit.Text.Trim(),16);
currentS50.Sectors[currentSector].Block[1] = Utils.Hex2Block(block1Edit.Text.Trim(), 16);
currentS50.Sectors[currentSector].Block[2] = Utils.Hex2Block(block2Edit.Text.Trim(), 16);
byte[] kA = Utils.Hex2Block(keyAEdit.Text.Trim(), 6);
byte[] kB = Utils.Hex2Block(keyBEdit.Text.Trim(), 6);
byte[] ac = new byte[4] {
(byte)comboBox1.SelectedIndex,
(byte)comboBox2.SelectedIndex,
@ -313,7 +304,7 @@ namespace MifareOneTool
}
}
richTextBox1.Clear();
logAppend(msg);
richTextBox1.Text = msg ;
}
}
@ -330,7 +321,7 @@ namespace MifareOneTool
MessageBox.Show("输入的UID号不合法", "InputError", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
buid = Hex2Block(uid, 4);
buid = Utils.Hex2Block(uid, 4);
byte bcc=(byte)(buid[0]^buid[1]^buid[2]^buid[3]);
currentS50.Sectors[0].Block[0][0] = buid[0];
currentS50.Sectors[0].Block[0][1] = buid[1];
@ -395,7 +386,7 @@ namespace MifareOneTool
}
}
richTextBox1.Clear();
logAppend(msg);
richTextBox1.Text=msg;
}
}
@ -448,19 +439,48 @@ namespace MifareOneTool
logAppend("已导出密钥字典文件" + filename + "。");
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{//测试后门
StreamWriter sw = File.CreateText("x.dic");
for (int i = 0; i < 4000 * 32; i++)
private void MCT格式ToolStripMenuItem_Click(object sender, EventArgs e)
{
reloadEdit(-1);
OpenFileDialog ofd = new OpenFileDialog();
ofd.CheckFileExists = true;
ofd.Filter = "MCT格式|*.*";
ofd.Title = "请选择需要打开的MCT格式文件";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
byte[] keyn = new byte[6];
rng.GetBytes(keyn);
sw.WriteLine(Utils.Hex2Str(keyn));
sw.Flush();
currentFilename = ofd.FileName;
}
sw.Flush();
sw.Close();
else
{
return;
}
this.currentS50 = new S50();
try
{
this.currentS50.LoadFromMctTxt(currentFilename);
}
catch (IOException ioe)
{
MessageBox.Show(ioe.Message, "打开出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.currentS50 = new S50();
return;
}
reloadList();
logAppend("打开了" + ofd.FileName);
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 16; i++)
{
sb.AppendLine("#扇区 " + i.ToString());
sb.AppendLine("[A] " + Utils.Hex2Str(this.currentS50.Sectors[i].KeyA));
sb.AppendLine("[B] " + Utils.Hex2Str(this.currentS50.Sectors[i].KeyB));
}
richTextBox1.Clear();
richTextBox1.Text = sb.ToString();
}
}
}

View File

@ -123,6 +123,9 @@
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="s50BindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>155, 17</value>
</metadata>

View File

@ -67,6 +67,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClassMfClassic.cs" />
<Compile Include="ClassMifareS50.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.6.1.0")]
[assembly: AssemblyFileVersion("1.6.1.0")]