Support Mifare Simulate and Sniff function

This commit is contained in:
wh201906
2020-05-09 23:43:10 +08:00
parent 5816d1b1b6
commit 2790afc193
5 changed files with 440 additions and 209 deletions
+49 -47
View File
@@ -50,7 +50,6 @@ void MainWindow::initUI() // will be called by main.app
void MainWindow::on_PM3_refreshPortButton_clicked()
{
ui->PM3_portBox->clear();
ui->PM3_portBox->addItem("");
QSerialPort serial;
QStringList serialList;
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
@@ -493,6 +492,55 @@ void MainWindow::on_MF_Sim_clearButton_clicked()
mifare->wipeE();
}
void MainWindow::on_MF_Sim_simButton_clicked()
{
mifare->simulate();
}
void MainWindow::on_MF_Sniff_loadButton_clicked() // use a tmp file to support complicated path
{
QString title = "";
QString filename = "";
title = tr("Plz select the trace file:");
filename = QFileDialog::getOpenFileName(this, title, "./", tr("Trace Files(*.trc);;All Files(*.*)"));
qDebug() << filename;
if(filename != "")
{
QString tmpFile = "tmp" + QString::number(QDateTime::currentDateTime().toTime_t()) + ".trc";
if(QFile::copy(filename, "./" + tmpFile))
{
mifare->loadSniff(tmpFile);
QFile::remove("./" + tmpFile);
}
else
{
QMessageBox::information(this, tr("Info"), tr("Failed to open") + "\n" + filename);
}
}
}
void MainWindow::on_MF_Sniff_saveButton_clicked()
{
QString title = "";
QString filename = "";
title = tr("Plz select the location to save trace file:");
filename = QFileDialog::getSaveFileName(this, title, "./", tr("Trace Files(*.trc)"));
qDebug() << filename;
if(filename != "")
{
QString tmpFile = "tmp" + QString::number(QDateTime::currentDateTime().toTime_t()) + ".trc";
mifare->saveSniff(tmpFile);
if(!QFile::copy("./" + tmpFile, filename))
{
QMessageBox::information(this, tr("Info"), tr("Failed to save to") + "\n" + filename);
}
QFile::remove("./" + tmpFile);
}
}
void MainWindow::on_MF_Sniff_sniffButton_clicked()
{
setState(false);
@@ -674,50 +722,4 @@ void MainWindow::setState(bool st)
void MainWindow::on_MF_Sim_simButton_clicked()
{
mifare->simulate();
}
void MainWindow::on_MF_Sniff_loadButton_clicked() // use a tmp file to support complicated path
{
QString title = "";
QString filename = "";
title = tr("Plz select the trace file:");
filename = QFileDialog::getOpenFileName(this, title, "./", tr("Trace Files(*.trc);;All Files(*.*)"));
qDebug() << filename;
if(filename != "")
{
QString tmpFile = "tmp" + QString::number(QDateTime::currentDateTime().toTime_t()) + ".trc";
if(QFile::copy(filename, "./" + tmpFile))
{
mifare->loadSniff(tmpFile);
QFile::remove("./" + tmpFile);
}
else
{
QMessageBox::information(this, tr("Info"), tr("Failed to open") + "\n" + filename);
}
}
}
void MainWindow::on_MF_Sniff_saveButton_clicked()
{
QString title = "";
QString filename = "";
title = tr("Plz select the location to save trace file:");
filename = QFileDialog::getSaveFileName(this, title, "./", tr("Trace Files(*.trc)"));
qDebug() << filename;
if(filename != "")
{
QString tmpFile = "tmp" + QString::number(QDateTime::currentDateTime().toTime_t()) + ".trc";
mifare->saveSniff(tmpFile);
if(!QFile::copy("./" + tmpFile, filename))
{
QMessageBox::information(this, tr("Info"), tr("Failed to save to") + "\n" + filename);
}
}
}
+7
View File
@@ -608,6 +608,13 @@
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Data:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
+2 -2
View File
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Simulate</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
@@ -299,7 +299,7 @@
</sizepolicy>
</property>
<property name="text">
<string> Generate random nonces instead of sequential nonces. Standard reader attack won't work with this option, only moebius attack works.</string>
<string>Generate random nonces instead of sequential nonces. Standard reader attack won't work with this option, only moebius attack works</string>
</property>
<property name="wordWrap">
<bool>true</bool>