private void Check_Clipboard() { while (true) { if (registerAmiiboKeyToolStripMenuItem.Checked) { try { IDataObject ClipData = Clipboard.GetDataObject(); if (ClipData.GetData(DataFormats.Text) != null) { if (ClipData.GetDataPresent(DataFormats.Text)) { string Clipboard_Text = ClipData.GetData(DataFormats.Text).ToString(); Clipboard_Text = Regex.Replace(Clipboard_Text, "[^a-zA-Z0-9-]", string.Empty); if (Clipboard_Text.Length == 320) { if (Helper_Class.ValidSHA1(Helper_Class.String_To_Byte_Array(Clipboard_Text), Amiibo_Keys_Hash)) { this.Invoke(new Action(() => { Helper_Class.FlashWindowEx(this); DialogResult DgResult = MessageBox.Show(this, i18n.__("Clipboard_Key_Message1"), this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DgResult == DialogResult.Yes) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = i18n.__("Clipboard_Key_Filter", "|*.bin"); saveFileDialog1.Title = i18n.__("Clipboard_Key_Title"); if (saveFileDialog1.ShowDialog(this) == DialogResult.OK && saveFileDialog1.FileName != "") { byte[] clipboardStringBytes = Helper_Class.String_To_Byte_Array(Clipboard_Text); Helper_Class.ByteArrayToFile(saveFileDialog1.FileName, clipboardStringBytes); MessageBox.Show(this, i18n.__("Clipboard_Key_Message2"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Clipboard.SetDataObject(""); } } else { Clipboard.SetDataObject(""); } })); } } } } } catch (Exception) {} } Application.DoEvents(); } }
public static byte[] Generate_Password(string Long_UID) { int Padding = 0; if (Long_UID.Length == 9 * 2) { Padding = 2; } int pw1 = 0xAA ^ Convert.ToInt32(Long_UID.Substring(2, 2), 16) ^ Convert.ToInt32(Long_UID.Substring(6 + Padding, 2), 16); int pw2 = 0x55 ^ Convert.ToInt32(Long_UID.Substring(4, 2), 16) ^ Convert.ToInt32(Long_UID.Substring(8 + Padding, 2), 16); int pw3 = 0xAA ^ Convert.ToInt32(Long_UID.Substring(6 + Padding, 2), 16) ^ Convert.ToInt32(Long_UID.Substring(10 + Padding, 2), 16); int pw4 = 0x55 ^ Convert.ToInt32(Long_UID.Substring(8 + Padding, 2), 16) ^ Convert.ToInt32(Long_UID.Substring(12 + Padding, 2), 16); return(Helper_Class.String_To_Byte_Array(pw1.ToString("X2") + pw2.ToString("X2") + pw3.ToString("X2") + pw4.ToString("X2"))); }
public static byte[] Calculate_Long_UID(string Short_UID) { /* * 0x00 - UID0 - Manufacturer Code (0x04 for NXP - random if spoofed) * 0x01 - UID1 * 0x02 - UID2 * 0x03 - BCC0 - 0x88 ^ UID0 ^ UID1 ^ UID2 * 0x04 - UID3 (Never 0x88) * 0x05 - UID4 * 0x06 - UID5 * 0x07 - UID6 * 0x08 - BCC1 - UID3 ^ UID4 ^ UID5 ^ UID6 */ int BCC0 = 0x88 ^ Convert.ToInt32(Short_UID.Substring(0, 2), 16) ^ Convert.ToInt32(Short_UID.Substring(2, 2), 16) ^ Convert.ToInt32(Short_UID.Substring(4, 2), 16); int BCC1 = Convert.ToInt32(Short_UID.Substring(6, 2), 16) ^ Convert.ToInt32(Short_UID.Substring(8, 2), 16) ^ Convert.ToInt32(Short_UID.Substring(10, 2), 16) ^ Convert.ToInt32(Short_UID.Substring(12, 2), 16); return(Helper_Class.String_To_Byte_Array(Short_UID.Substring(0, 6) + BCC0.ToString("X2") + Short_UID.Substring(6, 8) + BCC1.ToString("X2"))); }
private async void button2_Click(object sender, EventArgs e) { comboBox1.Enabled = false; comboBox2.Enabled = false; comboBox3.Enabled = false; checkBox1.Enabled = false; button2.Enabled = false; textBox1.Text = ""; if (comboBox3.SelectedIndex == 0) { Arduino = new Arduino_Class(comboBox1.SelectedValue.ToString(), comboBox2.SelectedItem.ToString()); if (Arduino.Serial.IsOpen) { toolStripStatusLabel1.Text = i18n.__("NFC_Connected"); string DeviceNFC = i18n.__("NFC_NTAG215"); if (!Action_Write) { DeviceNFC = i18n.__("NFC_Amiibo_NTAG215"); } MessageBox.Show(i18n.__("NFC_Put_NTAG1", DeviceNFC) + Environment.NewLine + i18n.__("NFC_Put_NTAG2"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Text = i18n.__("NFC_Wait_NTAG"); await Task.Run(() => { while (!NTAG_isHere()) { } }); textBox1.AppendText(i18n.__("NFC_Found_NTAG") + Environment.NewLine + Environment.NewLine); string NTAG_Short_UID = Arduino.SendCommand("/GET_NTAG_UID"); if (NTAG_Short_UID.Length == 14) { if (Action_Write) { textBox1.AppendText(i18n.__("NFC_Short_UID") + " " + NTAG_Short_UID + Environment.NewLine); string NTAG_Long_UID = BitConverter.ToString(Amiibo_Class.Calculate_Long_UID(NTAG_Short_UID)).Replace("-", ""); textBox1.AppendText(i18n.__("NFC_Long_UID") + " " + NTAG_Long_UID + Environment.NewLine + Environment.NewLine); byte[] Amiibo_Data = Amiibo_Class.Patch(File.ReadAllBytes(Current_File_Bin), NTAG_Long_UID); textBox1.AppendText("\"" + Current_File_Bin + "\" " + i18n.__("NFC_Patched") + Environment.NewLine); if (checkBox1.Checked) { Arduino.SendCommand("/WRITE_AMIIBO 1"); } else { Arduino.SendCommand("/WRITE_AMIIBO 0"); } string Result = Arduino.SendCommand(Amiibo_Data); textBox1.AppendText("\"" + Current_File_Bin + "\" " + i18n.__("NFC_Send") + Environment.NewLine + Environment.NewLine); if (Result.Split('/', ' ')[1] == "ERROR") { textBox1.AppendText(i18n.__("NFC_Error") + " " + Result.Substring(1) + Environment.NewLine); } else if (Result.Split('/', ' ')[1] == "END_WRITE") { textBox1.AppendText(i18n.__("NFC_Amiibo_Ready") + Environment.NewLine); } else { textBox1.AppendText(i18n.__("NFC_Unknown_Response") + " " + Result + Environment.NewLine); } } else { byte[] Amiibo_Dump = new byte[540]; int i; for (i = 0; i < 135; i++) { string Result = Arduino.SendCommand("/READ_AMIIBO " + i); string[] SplitResult = Result.Split('/', ' '); if (SplitResult.Length > 1) { if (Result.Split('/', ' ')[1] == "ERROR") { textBox1.AppendText(i18n.__("NFC_Error") + " " + Result.Substring(1) + Environment.NewLine); } else { textBox1.AppendText(i18n.__("NFC_Unknown_Response") + " " + Result + Environment.NewLine); } i = 135; } else { textBox1.AppendText(i18n.__("NFC_Page_Readed", (i + 1)) + Environment.NewLine); byte[] Buffer = Helper_Class.String_To_Byte_Array(Result); Array.Copy(Buffer, 0, Amiibo_Dump, i * 4, Buffer.Length); } } if (i == 135) { textBox1.AppendText(i18n.__("NFC_Reading_Finished") + Environment.NewLine); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = i18n.__("NFC_Save_Dump_Amiibo_Filter", "|*.bin"); saveFileDialog1.Title = i18n.__("NFC_Save_Dump_Amiibo_Title"); saveFileDialog1.InitialDirectory = Bin_Folder; byte[] Decrypted_Amiibo = Amiibo_Class.Decrypt(Amiibo_Dump, Main_Form.AmiiKeys); string[] AmiiboLife_Info = AmiiboInfo_Class.Get_AmiiboInfo(Amiibo_Class.Get_NFC_ID(Decrypted_Amiibo)); byte[] UID = new byte[0x07]; Array.Copy(Amiibo_Dump, 0, UID, 0, UID.Length); saveFileDialog1.FileName = ((AmiiboLife_Info[0].Trim() != "") ? AmiiboLife_Info[0].Trim().Replace(" ", "_") : BitConverter.ToString(UID).Replace("-", "")) + ".bin"; if (saveFileDialog1.ShowDialog(this.Parent) == DialogResult.OK && saveFileDialog1.FileName != "") { File.WriteAllBytes(saveFileDialog1.FileName, Amiibo_Dump); MessageBox.Show(this, i18n.__("NFC_Save_Dump_Amiibo_Message"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else { textBox1.AppendText(i18n.__("NFC_Wrong_Tag_Model") + Environment.NewLine); } Arduino.SendCommand("/NTAG_HALT"); Arduino.Close(); } else { toolStripStatusLabel1.Text = i18n.__("NFC_No_Connected"); MessageBox.Show(i18n.__("NFC_No_Connection"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } comboBox1.Enabled = true; //comboBox2.Enabled = true; comboBox3.Enabled = true; checkBox1.Enabled = true; button2.Enabled = true; } else { } }