From f8d2bbb2062abd8cc3d05c3762b730ec2ad01c02 Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sun, 9 Aug 2020 10:32:48 +0800 Subject: [PATCH 1/2] Fix Trailer Decoder and add write feedback --- module/mifare.cpp | 46 +++++++++++++++++++++++++++++++++++++++------- module/mifare.h | 2 +- ui/mainwindow.cpp | 17 +++++++---------- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/module/mifare.cpp b/module/mifare.cpp index ad34915..5c0f63e 100644 --- a/module/mifare.cpp +++ b/module/mifare.cpp @@ -36,19 +36,19 @@ const Mifare::CardType Mifare::card_4k = const Mifare::AccessType Mifare::dataCondition[8][4] = { {ACC_KEY_AB, ACC_KEY_AB, ACC_KEY_AB, ACC_KEY_AB}, - {ACC_KEY_AB, ACC_NEVER, ACC_NEVER, ACC_NEVER}, {ACC_KEY_AB, ACC_KEY_B, ACC_NEVER, ACC_NEVER}, + {ACC_KEY_AB, ACC_NEVER, ACC_NEVER, ACC_NEVER}, {ACC_KEY_AB, ACC_KEY_B, ACC_KEY_B, ACC_KEY_AB}, {ACC_KEY_AB, ACC_NEVER, ACC_NEVER, ACC_KEY_AB}, - {ACC_KEY_B, ACC_KEY_B, ACC_NEVER, ACC_NEVER}, {ACC_KEY_B, ACC_NEVER, ACC_NEVER, ACC_NEVER}, + {ACC_KEY_B, ACC_KEY_B, ACC_NEVER, ACC_NEVER}, {ACC_NEVER, ACC_NEVER, ACC_NEVER, ACC_NEVER}, }; const Mifare::AccessType Mifare::trailerReadCondition[8][3] = { - {ACC_NEVER, ACC_KEY_A, ACC_KEY_A}, {ACC_NEVER, ACC_KEY_A, ACC_KEY_A}, {ACC_NEVER, ACC_KEY_AB, ACC_NEVER}, + {ACC_NEVER, ACC_KEY_A, ACC_KEY_A}, {ACC_NEVER, ACC_KEY_AB, ACC_NEVER}, {ACC_NEVER, ACC_KEY_A, ACC_KEY_A}, {ACC_NEVER, ACC_KEY_AB, ACC_NEVER}, @@ -58,12 +58,12 @@ const Mifare::AccessType Mifare::trailerReadCondition[8][3] = const Mifare::AccessType Mifare::trailerWriteCondition[8][3] = { {ACC_KEY_A, ACC_NEVER, ACC_KEY_A}, - {ACC_NEVER, ACC_NEVER, ACC_NEVER}, {ACC_KEY_B, ACC_NEVER, ACC_KEY_B}, {ACC_NEVER, ACC_NEVER, ACC_NEVER}, + {ACC_NEVER, ACC_NEVER, ACC_NEVER}, {ACC_KEY_A, ACC_KEY_A, ACC_KEY_A}, - {ACC_KEY_B, ACC_KEY_B, ACC_KEY_B}, {ACC_NEVER, ACC_KEY_B, ACC_NEVER}, + {ACC_KEY_B, ACC_KEY_B, ACC_KEY_B}, {ACC_NEVER, ACC_NEVER, ACC_NEVER}, }; @@ -597,7 +597,7 @@ void Mifare::writeOne(TargetType targetType) } } -QList Mifare::writeSelected(TargetType targetType) +void Mifare::writeSelected(TargetType targetType) { QList failedBlocks; QList selectedBlocks; @@ -630,7 +630,39 @@ QList Mifare::writeSelected(TargetType targetType) failedBlocks.append(item); } } - return failedBlocks; + if(failedBlocks.size() == 0) + QMessageBox::information(parent, tr("Info"), tr("Successful!")); + else + { + QString suffix = ""; + int counter = 0; + for(int failedBlk : failedBlocks) + { + suffix += QString::number(failedBlk) + " "; + counter++; + counter %= 20; + if(counter == 0) + suffix += "\n"; + } + QMessageBox::StandardButton res = QMessageBox::information(parent, tr("Info"), tr("Failed to write to these blocks:") + + "\n" + + suffix + + "\n" + + tr("Select them?"), + QMessageBox::Yes | QMessageBox::No); + if(res == QMessageBox::Yes) + { + for(int item : selectedBlocks) + { + ui->MF_dataWidget->item(item, 1)->setCheckState(Qt::Unchecked); + } + for(int failedBlk : failedBlocks) + { + ui->MF_dataWidget->item(failedBlk, 1)->setCheckState(Qt::Checked); + } + } + + } } void Mifare::dump() diff --git a/module/mifare.h b/module/mifare.h index 3223f67..7865755 100644 --- a/module/mifare.h +++ b/module/mifare.h @@ -73,7 +73,7 @@ public: void readOne(TargetType targetType = TARGET_MIFARE); void readSelected(TargetType targetType = TARGET_MIFARE); void writeOne(TargetType targetType = TARGET_MIFARE); - QList writeSelected(TargetType targetType = TARGET_MIFARE); + void writeSelected(TargetType targetType = TARGET_MIFARE); void dump(); void restore(); diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index fc350cf..2b30c0f 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -580,9 +580,8 @@ void MainWindow::on_MF_RW_writeBlockButton_clicked() void MainWindow::on_MF_RW_writeSelectedButton_clicked() { - QList failedBlocks; setState(false); - failedBlocks = mifare->writeSelected(Mifare::TARGET_MIFARE); + mifare->writeSelected(Mifare::TARGET_MIFARE); setState(true); } @@ -612,9 +611,8 @@ void MainWindow::on_MF_UID_readBlockButton_clicked() void MainWindow::on_MF_UID_writeSelectedButton_clicked() { - QList failedBlocks; setState(false); - failedBlocks = mifare->writeSelected(Mifare::TARGET_UID); + mifare->writeSelected(Mifare::TARGET_UID); setState(true); } @@ -672,9 +670,8 @@ void MainWindow::on_MF_Sim_readSelectedButton_clicked() void MainWindow::on_MF_Sim_writeSelectedButton_clicked() { - QList failedBlocks; setState(false); - failedBlocks = mifare->writeSelected(Mifare::TARGET_EMULATOR); + mifare->writeSelected(Mifare::TARGET_EMULATOR); setState(true); } @@ -891,7 +888,7 @@ void MainWindow::signalInit() connect(ui->MF_sniffGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked); } -void MainWindow::setStatusBar(QLabel* target, const QString & text) +void MainWindow::setStatusBar(QLabel * target, const QString & text) { if(target == PM3VersionBar) target->setText(tr("HW Version:") + text); @@ -901,14 +898,14 @@ void MainWindow::setStatusBar(QLabel* target, const QString & text) target->setText(tr("State:") + text); } -void MainWindow::setTableItem(QTableWidget* widget, int row, int column, const QString& text) +void MainWindow::setTableItem(QTableWidget * widget, int row, int column, const QString & text) { if(widget->item(row, column) == nullptr) widget->setItem(row, column, new QTableWidgetItem()); widget->item(row, column)->setText(text); } -bool MainWindow::eventFilter(QObject *watched, QEvent *event) // drag support +bool MainWindow::eventFilter(QObject * watched, QEvent * event) // drag support { if(event->type() == QEvent::DragEnter) { @@ -986,7 +983,7 @@ void MainWindow::on_GroupBox_clicked(bool checked) settings->endGroup(); } -void MainWindow::saveClientPath(const QString& path) +void MainWindow::saveClientPath(const QString & path) { settings->beginGroup("Client_Path"); settings->setValue("path", path); From 3a577bdd32b6217f7e8a3b9279a837362c5e2c20 Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sun, 9 Aug 2020 10:33:15 +0800 Subject: [PATCH 2/2] V0.1.3 --- Proxmark3GUI.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Proxmark3GUI.pro b/Proxmark3GUI.pro index bfdf6a5..85feb73 100644 --- a/Proxmark3GUI.pro +++ b/Proxmark3GUI.pro @@ -52,7 +52,7 @@ qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target -VERSION = 0.1.2 +VERSION = 0.1.3 QMAKE_TARGET_PRODUCT = "Proxmark3GUI" QMAKE_TARGET_DESCRIPTION = "Proxmark3GUI" QMAKE_TARGET_COMPANY = "wh201906"