private async void btnSelectDump_Click(object sender, RoutedEventArgs e)
        {
            var dr = ofd.ShowDialog();

            if (dr.Value)
            {
                tools.TMPFILESOURCE_MFD    = Path.GetFileName(ofd.FileName);
                lblSrcDumpValue.Content    = Path.GetFileName(tools.TMPFILESOURCE_MFD);
                lblTargetDumpValue.Content = Path.GetFileName(tools.TMPFILE_TARGETMFD);
            }
            if (string.IsNullOrWhiteSpace(lblTargetDumpValue.Content?.ToString()))
            {
                MapKeyToSectorWindow mtsWin = new MapKeyToSectorWindow(main, tools, Translate.Key(nameof(MifareWindowsTool.Properties.Resources.UsedForTargetMapping)), Translate.Key(nameof(MifareWindowsTool.Properties.Resources.TargetDump)));
                var ret = mtsWin.ShowDialog();
                if (ret.HasValue && ret.Value)
                {
                    await main.RunMfocAsync(main.SelectedKeys, tools.TMPFILESOURCE_MFD, TagAction.ReadSource);
                }
            }
        }
Exemplo n.º 2
0
        private async Task ReadTagAsync(TagAction act)
        {
            if (t.running)
            {
                return;
            }
            DumpFound = false;
            if (!TagFound && !ScanTagRunning)
            {
                PeriodicScanTag();
            }

            if (!ckEnablePeriodicTagScan.IsChecked.HasValue || !ckEnablePeriodicTagScan.IsChecked.Value)
            {
                await RunNfcListAsync();
            }

            if (!string.IsNullOrWhiteSpace(t.CurrentUID))
            {
                if (act == TagAction.ReadSource)
                {
                    t.mySourceUID       = t.CurrentUID;
                    t.TMPFILE_UNK       = $"mfc_{ t.mySourceUID}_unknownMfocSectorInfo.txt";
                    t.TMPFILESOURCE_MFD = $"mfc_{ t.mySourceUID}.dump";
                    t.TMPFILE_FND       = $"mfc_{ t.mySourceUID}_foundKeys.txt";
                    if (t.CheckAndUseDumpIfExists(t.TMPFILESOURCE_MFD))
                    {
                        DumpFound = true;
                    }
                }
                else if (act == TagAction.ReadTarget)
                {
                    t.myTargetUID       = t.CurrentUID;
                    t.TMPFILE_UNK       = $"mfc_{ t.myTargetUID}_unknownMfocSectorInfo.txt";
                    t.TMPFILE_TARGETMFD = $"mfc_{ t.myTargetUID}.dump";
                    t.TMPFILE_FND       = $"mfc_{ t.myTargetUID}_foundKeys.txt";
                    if (t.CheckAndUseDumpIfExists(t.TMPFILE_TARGETMFD))
                    {
                        DumpFound = true;
                    }
                }
            }

            if (TagFound)
            {
                StopScanTag();
                if (act == TagAction.ReadSource)
                {
                    if (!DumpFound)
                    {
                        MapKeyToSectorWindow mtsWin = new MapKeyToSectorWindow(this, t, Translate.Key(nameof(MifareWindowsTool.Properties.Resources.UsedForSourceMapping)), Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Source)));
                        var ret = mtsWin.ShowDialog();
                        if (ret.HasValue && ret.Value)
                        {
                            await RunMfocAsync(SelectedKeys, t.TMPFILESOURCE_MFD, act);

                            if (StdOutMfoc.Contains($"dumping keys to a file"))
                            {
                                ShowDump("dumps\\" + t.TMPFILESOURCE_MFD);
                                StdOutMfoc = string.Empty;
                            }
                        }
                        else
                        {
                            PeriodicScanTag();
                        }
                    }
                    else
                    {
                        ShowDump("dumps\\" + t.TMPFILESOURCE_MFD);
                    }
                }
                else if (act == TagAction.ReadTarget)
                {
                    if (!DumpFound)
                    {
                        MapKeyToSectorWindow mtsWin = new MapKeyToSectorWindow(this, t, Translate.Key(nameof(MifareWindowsTool.Properties.Resources.UsedForTargetMapping)), Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Target)));
                        var ret = mtsWin.ShowDialog();
                        if (ret.HasValue && ret.Value)
                        {
                            await RunMfocAsync(SelectedKeys, t.TMPFILE_TARGETMFD, act);

                            if (StdOutMfoc.Contains($"dumping"))
                            {
                                OpenWriteDumpWindow();
                                StdOutMfoc = string.Empty;
                            }
                        }
                        else
                        {
                            PeriodicScanTag();
                        }
                    }
                    else
                    {
                        OpenWriteDumpWindow();
                    }
                }
            }
            else
            {
                LogAppend(Translate.Key(nameof(MifareWindowsTool.Properties.Resources.NoTagDetectedOnReader)));
            }
        }