diff --git a/Proxmark3GUI.pro b/Proxmark3GUI.pro index 44bdaa5..fb350ff 100644 --- a/Proxmark3GUI.pro +++ b/Proxmark3GUI.pro @@ -18,16 +18,19 @@ DEFINES += QT_DEPRECATED_WARNINGS SOURCES += \ main.cpp \ mainwindow.cpp \ + mf_attack_hardnesteddialog.cpp \ mifare.cpp \ pm3process.cpp HEADERS += \ mainwindow.h \ + mf_attack_hardnesteddialog.h \ mifare.h \ pm3process.h FORMS += \ - mainwindow.ui + mainwindow.ui \ + mf_attack_hardnesteddialog.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin diff --git a/mainwindow.cpp b/mainwindow.cpp index 270b71e..45d97f3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -36,7 +36,18 @@ void MainWindow::on_PM3_connectButton_clicked() if(port=="") QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok); else + { + pm3->setRequiringOutput(true); qDebug()<start(ui->PM3_pathEdit->text(),port); + while(pm3->waitForReadyRead()) + ; + QString result=pm3->getRequiredOutput(); + pm3->setRequiringOutput(false); + result=result.mid(result.indexOf("os: ")); + result=result.left(result.indexOf("\r\n")); + result=result.mid(3,result.lastIndexOf(" ")-3); + setStatusBar(PM3VersionBar,result); + } } void MainWindow::on_PM3_disconnectButton_clicked() @@ -100,12 +111,12 @@ void MainWindow::on_Raw_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item void MainWindow::on_MF_Attack_chkButton_clicked() { pm3->setRequiringOutput(true); - ui->Raw_CMDEdit->setText("hf mf chk *1 ?"); + execCMD("hf mf chk *1 ?",false); on_Raw_sendCMDButton_clicked(); - while(pm3->waitForReadyRead(5000)) + while(pm3->waitForReadyRead()) ; QString result=pm3->getRequiredOutput(); - pm3->setRequiringOutput(false); + pm3->setRequiringOutput(false); result=result.mid(result.indexOf("|---|----------------|----------------|")); QStringList keys=result.split("\r\n"); for(int i=0;i<16;i++) @@ -119,9 +130,8 @@ void MainWindow::on_MF_Attack_chkButton_clicked() void MainWindow::on_MF_Attack_nestedButton_clicked() { pm3->setRequiringOutput(true); - ui->Raw_CMDEdit->setText("hf mf nested 1 *"); - on_Raw_sendCMDButton_clicked(); - while(pm3->waitForReadyRead(5000)) + execCMD("hf mf nested 1 *",false); + while(pm3->waitForReadyRead()) ; QString result=pm3->getRequiredOutput(); pm3->setRequiringOutput(false); @@ -139,21 +149,19 @@ void MainWindow::on_MF_Attack_nestedButton_clicked() void MainWindow::on_MF_Attack_hardnestedButton_clicked() { - + MF_Attack_hardnestedDialog dialog; + connect(&dialog,&MF_Attack_hardnestedDialog::sendCMD,this,&MainWindow::execCMD); + dialog.exec(); } void MainWindow::on_MF_Attack_sniffButton_clicked() { - ui->Raw_CMDEdit->setText("hf mf sniff"); - on_Raw_sendCMDButton_clicked(); - ui->funcTab->setCurrentIndex(1); + execCMD("hf mf sniff",true); } void MainWindow::on_MF_Attack_listButton_clicked() { - ui->Raw_CMDEdit->setText("hf list mf"); - on_Raw_sendCMDButton_clicked(); - ui->funcTab->setCurrentIndex(1); + execCMD("hf list mf",true); } // ************************************************ @@ -231,11 +239,11 @@ void MainWindow::setStatusBar(QLabel* target,const QString & text) target->setText("Program State:"+text); } +void MainWindow::execCMD(QString cmd,bool gotoRawTab) +{ + ui->Raw_CMDEdit->setText(cmd); + on_Raw_sendCMDButton_clicked(); + if(gotoRawTab) + ui->funcTab->setCurrentIndex(1); +} // *********************************************** - - - - - - - diff --git a/mainwindow.h b/mainwindow.h index 570333f..c9241aa 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -8,6 +8,7 @@ #include #include "pm3process.h" #include "mifare.h" +#include "mf_attack_hardnesteddialog.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -24,6 +25,7 @@ public: public slots: void refresh(); void setStatusBar(QLabel* target,const QString & text); + void execCMD(QString cmd, bool gotoRawTab); private slots: void on_PM3_connectButton_clicked(); diff --git a/mainwindow.ui b/mainwindow.ui index 1857850..4deb05c 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -401,7 +401,11 @@ - + + + 63 + + @@ -603,7 +607,11 @@ - + + + 63 + + diff --git a/mf_attack_hardnesteddialog.cpp b/mf_attack_hardnesteddialog.cpp new file mode 100644 index 0000000..801ee78 --- /dev/null +++ b/mf_attack_hardnesteddialog.cpp @@ -0,0 +1,28 @@ +#include "mf_attack_hardnesteddialog.h" +#include "ui_mf_attack_hardnesteddialog.h" + +MF_Attack_hardnestedDialog::MF_Attack_hardnestedDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::MF_Attack_hardnestedDialog) +{ + ui->setupUi(this); +} + +MF_Attack_hardnestedDialog::~MF_Attack_hardnestedDialog() +{ + delete ui; +} + +void MF_Attack_hardnestedDialog::on_buttonBox_accepted() +{ + emit sendCMD("hf mf hardnested " + +ui->knownKeySectorBox->text() + +" " + +ui->knownKeyTypeBox->currentText() + +" " + +ui->knownKeyBox->text() + +" " + +ui->targetKeySectorBox->text() + +" " + +ui->targetKeyTypeBox->currentText()); +} diff --git a/mf_attack_hardnesteddialog.h b/mf_attack_hardnesteddialog.h new file mode 100644 index 0000000..d5c066f --- /dev/null +++ b/mf_attack_hardnesteddialog.h @@ -0,0 +1,27 @@ +#ifndef MF_ATTACK_HARDNESTEDDIALOG_H +#define MF_ATTACK_HARDNESTEDDIALOG_H + +#include + +namespace Ui { +class MF_Attack_hardnestedDialog; +} + +class MF_Attack_hardnestedDialog : public QDialog +{ + Q_OBJECT + +public: + explicit MF_Attack_hardnestedDialog(QWidget *parent = nullptr); + ~MF_Attack_hardnestedDialog(); + + +private: + Ui::MF_Attack_hardnestedDialog *ui; +signals: + void sendCMD(QString cmd, bool requireJump = true); +private slots: + void on_buttonBox_accepted(); +}; + +#endif // MF_ATTACK_HARDNESTEDDIALOG_H diff --git a/mf_attack_hardnesteddialog.ui b/mf_attack_hardnesteddialog.ui new file mode 100644 index 0000000..b9693e2 --- /dev/null +++ b/mf_attack_hardnesteddialog.ui @@ -0,0 +1,175 @@ + + + MF_Attack_hardnestedDialog + + + + 0 + 0 + 287 + 173 + + + + Dialog + + + + + + Known Key: + + + + + + + + + Block: + + + + + + + 63 + + + + + + + + A + + + + + B + + + + + + + + FFFFFFFFFFFF + + + + + + + + + Target Key: + + + + + + + + + Block: + + + + + + + 63 + + + + + + + + A + + + + + B + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 31 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + MF_Attack_hardnestedDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MF_Attack_hardnestedDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/pm3process.cpp b/pm3process.cpp index fdad430..52ce4b2 100644 --- a/pm3process.cpp +++ b/pm3process.cpp @@ -48,3 +48,8 @@ QString PM3Process::getRequiredOutput() { return *requiredOutput; } + +bool PM3Process::waitForReadyRead(int msecs) +{ + return QProcess::waitForReadyRead(msecs); +} diff --git a/pm3process.h b/pm3process.h index b24c742..c3e1563 100644 --- a/pm3process.h +++ b/pm3process.h @@ -17,6 +17,7 @@ public: QByteArray readLine(qint64 maxlen = 0); void setRequiringOutput(bool st); QString getRequiredOutput(); + bool waitForReadyRead(int msecs = 3000); private: bool isRequiringOutput; QString* requiredOutput;