mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2024-11-10 08:55:43 +08:00
Fix Trailer Decoder and add write feedback
This commit is contained in:
parent
d6beafe175
commit
f8d2bbb206
3 changed files with 47 additions and 18 deletions
|
@ -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<int> Mifare::writeSelected(TargetType targetType)
|
||||
void Mifare::writeSelected(TargetType targetType)
|
||||
{
|
||||
QList<int> failedBlocks;
|
||||
QList<int> selectedBlocks;
|
||||
|
@ -630,7 +630,39 @@ QList<int> 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()
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
void readOne(TargetType targetType = TARGET_MIFARE);
|
||||
void readSelected(TargetType targetType = TARGET_MIFARE);
|
||||
void writeOne(TargetType targetType = TARGET_MIFARE);
|
||||
QList<int> writeSelected(TargetType targetType = TARGET_MIFARE);
|
||||
void writeSelected(TargetType targetType = TARGET_MIFARE);
|
||||
void dump();
|
||||
void restore();
|
||||
|
||||
|
|
|
@ -580,9 +580,8 @@ void MainWindow::on_MF_RW_writeBlockButton_clicked()
|
|||
|
||||
void MainWindow::on_MF_RW_writeSelectedButton_clicked()
|
||||
{
|
||||
QList<int> 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<int> 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<int> 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);
|
||||
|
|
Loading…
Reference in a new issue