Add hardnested dialog

pull/2/head
wh201906 5 years ago
parent b3fd3ba378
commit 1d8d931752

@ -18,16 +18,19 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
mf_attack_hardnesteddialog.cpp \
mifare.cpp \ mifare.cpp \
pm3process.cpp pm3process.cpp
HEADERS += \ HEADERS += \
mainwindow.h \ mainwindow.h \
mf_attack_hardnesteddialog.h \
mifare.h \ mifare.h \
pm3process.h pm3process.h
FORMS += \ FORMS += \
mainwindow.ui mainwindow.ui \
mf_attack_hardnesteddialog.ui
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin

@ -36,7 +36,18 @@ void MainWindow::on_PM3_connectButton_clicked()
if(port=="") if(port=="")
QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok); QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok);
else else
{
pm3->setRequiringOutput(true);
qDebug()<<pm3->start(ui->PM3_pathEdit->text(),port); qDebug()<<pm3->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() void MainWindow::on_PM3_disconnectButton_clicked()
@ -100,9 +111,9 @@ void MainWindow::on_Raw_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item
void MainWindow::on_MF_Attack_chkButton_clicked() void MainWindow::on_MF_Attack_chkButton_clicked()
{ {
pm3->setRequiringOutput(true); pm3->setRequiringOutput(true);
ui->Raw_CMDEdit->setText("hf mf chk *1 ?"); execCMD("hf mf chk *1 ?",false);
on_Raw_sendCMDButton_clicked(); on_Raw_sendCMDButton_clicked();
while(pm3->waitForReadyRead(5000)) while(pm3->waitForReadyRead())
; ;
QString result=pm3->getRequiredOutput(); QString result=pm3->getRequiredOutput();
pm3->setRequiringOutput(false); pm3->setRequiringOutput(false);
@ -119,9 +130,8 @@ void MainWindow::on_MF_Attack_chkButton_clicked()
void MainWindow::on_MF_Attack_nestedButton_clicked() void MainWindow::on_MF_Attack_nestedButton_clicked()
{ {
pm3->setRequiringOutput(true); pm3->setRequiringOutput(true);
ui->Raw_CMDEdit->setText("hf mf nested 1 *"); execCMD("hf mf nested 1 *",false);
on_Raw_sendCMDButton_clicked(); while(pm3->waitForReadyRead())
while(pm3->waitForReadyRead(5000))
; ;
QString result=pm3->getRequiredOutput(); QString result=pm3->getRequiredOutput();
pm3->setRequiringOutput(false); pm3->setRequiringOutput(false);
@ -139,21 +149,19 @@ void MainWindow::on_MF_Attack_nestedButton_clicked()
void MainWindow::on_MF_Attack_hardnestedButton_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() void MainWindow::on_MF_Attack_sniffButton_clicked()
{ {
ui->Raw_CMDEdit->setText("hf mf sniff"); execCMD("hf mf sniff",true);
on_Raw_sendCMDButton_clicked();
ui->funcTab->setCurrentIndex(1);
} }
void MainWindow::on_MF_Attack_listButton_clicked() void MainWindow::on_MF_Attack_listButton_clicked()
{ {
ui->Raw_CMDEdit->setText("hf list mf"); execCMD("hf list mf",true);
on_Raw_sendCMDButton_clicked();
ui->funcTab->setCurrentIndex(1);
} }
// ************************************************ // ************************************************
@ -231,11 +239,11 @@ void MainWindow::setStatusBar(QLabel* target,const QString & text)
target->setText("Program State:"+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);
}
// *********************************************** // ***********************************************

@ -8,6 +8,7 @@
#include <QListWidgetItem> #include <QListWidgetItem>
#include "pm3process.h" #include "pm3process.h"
#include "mifare.h" #include "mifare.h"
#include "mf_attack_hardnesteddialog.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow; }
@ -24,6 +25,7 @@ public:
public slots: public slots:
void refresh(); void refresh();
void setStatusBar(QLabel* target,const QString & text); void setStatusBar(QLabel* target,const QString & text);
void execCMD(QString cmd, bool gotoRawTab);
private slots: private slots:
void on_PM3_connectButton_clicked(); void on_PM3_connectButton_clicked();

@ -401,7 +401,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="MF_RW_blockBox"/> <widget class="QSpinBox" name="MF_RW_blockBox">
<property name="maximum">
<number>63</number>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
@ -603,7 +607,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="MF_UID_blockBox"/> <widget class="QSpinBox" name="MF_UID_blockBox">
<property name="maximum">
<number>63</number>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="MF_UID_readBlockButton"> <widget class="QPushButton" name="MF_UID_readBlockButton">

@ -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());
}

@ -0,0 +1,27 @@
#ifndef MF_ATTACK_HARDNESTEDDIALOG_H
#define MF_ATTACK_HARDNESTEDDIALOG_H
#include <QDialog>
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

@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MF_Attack_hardnestedDialog</class>
<widget class="QDialog" name="MF_Attack_hardnestedDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>173</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Known Key:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Block:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="knownKeySectorBox">
<property name="maximum">
<number>63</number>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="knownKeyTypeBox">
<item>
<property name="text">
<string>A</string>
</property>
</item>
<item>
<property name="text">
<string>B</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLineEdit" name="knownKeyBox">
<property name="text">
<string>FFFFFFFFFFFF</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Target Key: </string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Block:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="targetKeySectorBox">
<property name="maximum">
<number>63</number>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="targetKeyTypeBox">
<item>
<property name="text">
<string>A</string>
</property>
</item>
<item>
<property name="text">
<string>B</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>MF_Attack_hardnestedDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>MF_Attack_hardnestedDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -48,3 +48,8 @@ QString PM3Process::getRequiredOutput()
{ {
return *requiredOutput; return *requiredOutput;
} }
bool PM3Process::waitForReadyRead(int msecs)
{
return QProcess::waitForReadyRead(msecs);
}

@ -17,6 +17,7 @@ public:
QByteArray readLine(qint64 maxlen = 0); QByteArray readLine(qint64 maxlen = 0);
void setRequiringOutput(bool st); void setRequiringOutput(bool st);
QString getRequiredOutput(); QString getRequiredOutput();
bool waitForReadyRead(int msecs = 3000);
private: private:
bool isRequiringOutput; bool isRequiringOutput;
QString* requiredOutput; QString* requiredOutput;

Loading…
Cancel
Save