From afe2474fe369df01847fbf2e235b5770615d6a9c Mon Sep 17 00:00:00 2001 From: wh201906 Date: Fri, 1 May 2020 23:37:23 +0800 Subject: [PATCH] Add UI for simulate function --- Proxmark3GUI.pro | 3 + module/mifare.cpp | 23 ++- module/mifare.h | 2 + ui/mainwindow.cpp | 5 + ui/mainwindow.h | 2 + ui/mf_sim_simdialog.cpp | 52 ++++++ ui/mf_sim_simdialog.h | 28 ++++ ui/mf_sim_simdialog.ui | 360 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 467 insertions(+), 8 deletions(-) create mode 100644 ui/mf_sim_simdialog.cpp create mode 100644 ui/mf_sim_simdialog.h create mode 100644 ui/mf_sim_simdialog.ui diff --git a/Proxmark3GUI.pro b/Proxmark3GUI.pro index 926190c..d0aabd4 100644 --- a/Proxmark3GUI.pro +++ b/Proxmark3GUI.pro @@ -20,6 +20,7 @@ SOURCES += \ common/pm3process.cpp \ common/util.cpp \ module/mifare.cpp \ + ui/mf_sim_simdialog.cpp \ ui/mf_uid_parameterdialog.cpp \ ui/mainwindow.cpp \ ui/mf_attack_hardnesteddialog.cpp \ @@ -28,11 +29,13 @@ HEADERS += \ common/pm3process.h \ common/util.h \ module/mifare.h \ + ui/mf_sim_simdialog.h \ ui/mf_uid_parameterdialog.h \ ui/mainwindow.h \ ui/mf_attack_hardnesteddialog.h \ FORMS += \ + ui/mf_sim_simdialog.ui \ ui/mf_uid_parameterdialog.ui \ ui/mainwindow.ui \ ui/mf_attack_hardnesteddialog.ui diff --git a/module/mifare.cpp b/module/mifare.cpp index 0ff483e..fe0d56d 100644 --- a/module/mifare.cpp +++ b/module/mifare.cpp @@ -445,6 +445,18 @@ void Mifare::writeAllC() } } +void Mifare::dump() +{ + util->execCMD("hf mf dump"); + ui->funcTab->setCurrentIndex(1); +} + +void Mifare::restore() +{ + util->execCMD("hf mf restore"); + ui->funcTab->setCurrentIndex(1); +} + void Mifare::wipeC() { util->execCMD( @@ -550,17 +562,12 @@ void Mifare::wipeE() util->execCMD("hf mf eclr"); } -void Mifare::dump() +void Mifare::simulate() { - util->execCMD("hf mf dump"); - ui->funcTab->setCurrentIndex(1); + MF_Sim_simDialog dialog; + dialog.exec(); } -void Mifare::restore() -{ - util->execCMD("hf mf restore"); - ui->funcTab->setCurrentIndex(1); -} void Mifare::data_syncWithDataWidget(bool syncAll, int block) { diff --git a/module/mifare.h b/module/mifare.h index 1c0926c..72c2c87 100644 --- a/module/mifare.h +++ b/module/mifare.h @@ -5,6 +5,7 @@ #include "ui_mainwindow.h" #include "ui/mf_attack_hardnesteddialog.h" #include "ui/mf_uid_parameterdialog.h" +#include "ui/mf_sim_simdialog.h" #include #include #include @@ -108,6 +109,7 @@ public: void writeAllE(); void readAllE(); void wipeE(); + void simulate(); public slots: signals: diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 740916a..21ec486 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -673,3 +673,8 @@ void MainWindow::setState(bool st) // *********************************************** + +void MainWindow::on_MF_Sim_simButton_clicked() +{ + mifare->simulate(); +} diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 5ecf277..cc3928b 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -126,6 +126,8 @@ private slots: void on_MF_Sim_clearButton_clicked(); + void on_MF_Sim_simButton_clicked(); + private: Ui::MainWindow* ui; QButtonGroup* typeBtnGroup; diff --git a/ui/mf_sim_simdialog.cpp b/ui/mf_sim_simdialog.cpp new file mode 100644 index 0000000..356239b --- /dev/null +++ b/ui/mf_sim_simdialog.cpp @@ -0,0 +1,52 @@ +#include "mf_sim_simdialog.h" +#include "ui_mf_sim_simdialog.h" + +MF_Sim_simDialog::MF_Sim_simDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::MF_Sim_simDialog) +{ + ui->setupUi(this); +} + +MF_Sim_simDialog::~MF_Sim_simDialog() +{ + delete ui; +} + +void MF_Sim_simDialog::on_eBox_clicked(bool checked) +{ + if(checked) + { + ui->iBox->setChecked(true); + ui->xBox->setChecked(true); + } + if(!ui->eBox->isChecked() && !ui->fBox->isChecked()) + { + ui->iBox->setEnabled(true); + ui->xBox->setEnabled(true); + } + else + { + ui->iBox->setEnabled(false); + ui->xBox->setEnabled(false); + } +} + +void MF_Sim_simDialog::on_fBox_clicked(bool checked) +{ + if(checked) + { + ui->iBox->setChecked(true); + ui->xBox->setChecked(true); + } + if(!ui->eBox->isChecked() && !ui->fBox->isChecked()) + { + ui->iBox->setEnabled(true); + ui->xBox->setEnabled(true); + } + else + { + ui->iBox->setEnabled(false); + ui->xBox->setEnabled(false); + } +} diff --git a/ui/mf_sim_simdialog.h b/ui/mf_sim_simdialog.h new file mode 100644 index 0000000..84be8d2 --- /dev/null +++ b/ui/mf_sim_simdialog.h @@ -0,0 +1,28 @@ +#ifndef MF_SIM_SIMDIALOG_H +#define MF_SIM_SIMDIALOG_H + +#include + +namespace Ui +{ +class MF_Sim_simDialog; +} + +class MF_Sim_simDialog : public QDialog +{ + Q_OBJECT + +public: + explicit MF_Sim_simDialog(QWidget *parent = nullptr); + ~MF_Sim_simDialog(); + +private slots: + void on_eBox_clicked(bool checked); + + void on_fBox_clicked(bool checked); + +private: + Ui::MF_Sim_simDialog *ui; +}; + +#endif // MF_SIM_SIMDIALOG_H diff --git a/ui/mf_sim_simdialog.ui b/ui/mf_sim_simdialog.ui new file mode 100644 index 0000000..d66bcc0 --- /dev/null +++ b/ui/mf_sim_simdialog.ui @@ -0,0 +1,360 @@ + + + MF_Sim_simDialog + + + + 0 + 0 + 461 + 351 + + + + Dialog + + + + 5 + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + + u + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + UID 4 or 7 bytes. If not specified, the UID 4B from emulator memory will be used + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + n + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Automatically exit simulation after <numreads> blocks have been read by reader. 0 = infinite + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + i + + + + + + + + 0 + 0 + + + + Interactive, means that console will not be returned until simulation finishes or is aborted + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + x + + + + + + + + 0 + 0 + + + + Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s) + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + e + + + + + + + + 0 + 0 + + + + set keys found from 'reader attack' to emulator memory (implies x and i) + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + f + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + get UIDs to use for 'reader attack' from file 'f <filename.txt>' (implies x and i) + + + true + + + + + + + + + Qt::Horizontal + + + + + + + + + r + + + + + + + + 0 + 0 + + + + Generate random nonces instead of sequential nonces. Standard reader attack won't work with this option, only moebius attack works. + + + true + + + + + + + + + Qt::Horizontal + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + MF_Sim_simDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MF_Sim_simDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +