Skip to content

Commit

Permalink
1.6.5半成
Browse files Browse the repository at this point in the history
  • Loading branch information
XAS-712 committed Feb 22, 2019
1 parent 543c45b commit 7c4f1d7
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 109 deletions.
49 changes: 39 additions & 10 deletions MifareOneTool/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 64 additions & 2 deletions MifareOneTool/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void default_rpt(object sender, ProgressChangedEventArgs e)
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);
Expand Down Expand Up @@ -101,6 +101,21 @@ void default_rpt(object sender, ProgressChangedEventArgs e)
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();

}
Expand Down Expand Up @@ -147,6 +162,7 @@ private void Form1_Load(object sender, EventArgs e)
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;
Expand Down Expand Up @@ -1226,7 +1242,15 @@ private void buttonHardNested_Click(object sender, EventArgs e)
{
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);
Expand All @@ -1240,6 +1264,10 @@ void Hardnest(object sender, DoWorkEventArgs e)
{
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;
Expand All @@ -1265,6 +1293,35 @@ void Hardnest(object sender, DoWorkEventArgs e)
}
}

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;
Expand Down Expand Up @@ -1303,5 +1360,10 @@ private void checkBoxAutoSave_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.AutoSave = checkBoxAutoSave.Checked;
}

private void checkBoxHardLowCost_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.HardLowCost = checkBoxHardLowCost.Checked;
}
}
}
3 changes: 0 additions & 3 deletions MifareOneTool/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
49 changes: 25 additions & 24 deletions MifareOneTool/FormHTool.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions MifareOneTool/FormHTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ private void buttonSaveSectorEdit_Click(object sender, EventArgs e)
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);
Expand Down Expand Up @@ -482,5 +484,10 @@ private void 列出全卡密钥ToolStripMenuItem_Click(object sender, EventArgs
richTextBox1.Clear();
richTextBox1.Text = sb.ToString();
}

private void FormHTool_Load(object sender, EventArgs e)
{
新建ToolStripMenuItem_Click(sender, e);
}
}
}
3 changes: 0 additions & 3 deletions MifareOneTool/FormHTool.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@
<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>
Expand Down
Loading

0 comments on commit 7c4f1d7

Please sign in to comment.