Support wipe(), lockUFUID(), setUIDParameter(),

in latest Iceman repo
Fix a error in keyPattern
Test all R/W functions in Iceman client and Official client
pull/14/head
wh201906 4 years ago
parent 24a6e1869b
commit 63f3424871

@ -49,6 +49,7 @@ QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
if(!isRunning) if(!isRunning)
break; break;
QApplication::processEvents(); QApplication::processEvents();
// qDebug() << "currOutput:" << *requiredOutput;
for(QString otpt : trigger.expectedOutputs) for(QString otpt : trigger.expectedOutputs)
{ {
re.setPattern(otpt); re.setPattern(otpt);

@ -83,8 +83,8 @@ Mifare::Mifare(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
data_clearKey(); // fill with blank QString data_clearKey(); // fill with blank QString
data_clearData(); // fill with blank QString data_clearData(); // fill with blank QString
dataPattern = new QRegularExpression("([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}"); dataPattern = new QRegularExpression("([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}");
keyPattern_res = new QRegularExpression("\\|\\s+\\d{3}\\s+\\|\\s+.+?\\s+\\|\\s+.+?\\s+\\|\\s+.+?\\s+\\|\\s+.+?\\s+\\|"); keyPattern_res = new QRegularExpression("\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|");
keyPattern = new QRegularExpression("\\|\\s+\\d{3}\\s+\\|\\s+.+?\\s+\\|\\s+.+?\\s+\\|"); keyPattern = new QRegularExpression("\\|\\s*\\d{3}\\s*\\|\\s*.+?\\s*\\|\\s*.+?\\s*\\|");
} }
QString Mifare::info(bool isRequiringOutput) QString Mifare::info(bool isRequiringOutput)
@ -94,15 +94,13 @@ QString Mifare::info(bool isRequiringOutput)
if(isRequiringOutput) if(isRequiringOutput)
{ {
QString result = util->execCMDWithOutput("hf 14a info", 500); QString result = util->execCMDWithOutput("hf 14a info", 500);
result.replace("UID :", "|||"); int begin, end;
result.replace("ATQA :", "|||"); begin = result.indexOf("UID");
result.replace("SAK :", "|||"); if(begin != -1)
result.replace("TYPE :", "|||");
QStringList lis = result.split("|||");
if(lis.length() > 4)
{ {
qDebug() << lis[1] + lis[2] + lis[3]; end = result.indexOf("SAK", begin);
return lis[1] + lis[2] + lis[3]; end = result.indexOf("\n", end);
return result.mid(begin, end - begin + 1);
} }
else else
return ""; return "";
@ -128,7 +126,8 @@ void Mifare::chk()
"hf mf chk *" "hf mf chk *"
+ QString::number(cardType.type) + QString::number(cardType.type)
+ " ?", + " ?",
Util::ReturnTrigger(1000 + cardType.sector_size * 200, {"No valid", "\\|---\\|----------------\\|----------------\\|"})); Util::ReturnTrigger(1000 + cardType.sector_size * 200, {"No valid", keyPattern->pattern()}));
qDebug() << result;
for(int i = 0; i < cardType.sector_size; i++) for(int i = 0; i < cardType.sector_size; i++)
{ {
reMatch = keyPattern->match(result, offset); reMatch = keyPattern->match(result, offset);
@ -610,7 +609,7 @@ bool Mifare::_writeblk(int blockId, KeyType keyType, const QString& key, const Q
+ " " + " "
+ input, + input,
waitTime); waitTime);
return (result.indexOf("Chinese magic") != -1); return (result.indexOf("error") == -1); // failed flag
} }
else if(targetType == TARGET_EMULATOR) else if(targetType == TARGET_EMULATOR)
{ {
@ -747,10 +746,17 @@ void Mifare::restore()
void Mifare::wipeC() void Mifare::wipeC()
{ {
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL)
{
util->execCMD( util->execCMD(
"hf mf cwipe " "hf mf cwipe "
+ QString::number(cardType.type) + QString::number(cardType.type)
+ " f"); + " f");
}
else if(util->getClientType() == Util::CLIENTTYPE_ICEMAN)
{
util->execCMD("hf mf cwipe");
}
ui->funcTab->setCurrentIndex(Util::rawTabIndex); ui->funcTab->setCurrentIndex(Util::rawTabIndex);
} }
@ -761,11 +767,15 @@ void Mifare::setParameterC()
QMessageBox::information(parent, tr("Info"), tr("Failed to read card.")); QMessageBox::information(parent, tr("Info"), tr("Failed to read card."));
else else
{ {
QStringList lis = result.split("\r\n"); result.replace("\r\n", "");
lis[0].replace(" ", ""); result.replace(QRegularExpression("\\[.\\]"), "");
lis[1].replace(" ", ""); result.replace("UID", "");
lis[2].replace(" ", ""); result.replace("ATQA", "");
MF_UID_parameterDialog dialog(lis[0].toUpper(), lis[1].toUpper(), lis[2].mid(0, 2).toUpper()); result.replace("SAK", "");
result.replace(" ", "");
QStringList lis = result.split(':');
qDebug() << lis;
MF_UID_parameterDialog dialog(lis[1].toUpper(), lis[2].toUpper(), lis[3].toUpper());
connect(&dialog, &MF_UID_parameterDialog::sendCMD, util, &Util::execCMD); connect(&dialog, &MF_UID_parameterDialog::sendCMD, util, &Util::execCMD);
if(dialog.exec() == QDialog::Accepted) if(dialog.exec() == QDialog::Accepted)
ui->funcTab->setCurrentIndex(Util::rawTabIndex); ui->funcTab->setCurrentIndex(Util::rawTabIndex);
@ -774,12 +784,24 @@ void Mifare::setParameterC()
void Mifare::lockC() void Mifare::lockC()
{ {
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL)
{
util->execCMD("hf 14a raw -pa -b7 40"); util->execCMD("hf 14a raw -pa -b7 40");
util->execCMD("hf 14a raw -pa 43"); util->execCMD("hf 14a raw -pa 43");
util->execCMD("hf 14a raw -pa E0 00 39 F7"); util->execCMD("hf 14a raw -pa E0 00 39 F7");
util->execCMD("hf 14a raw -pa E1 00 E1 EE"); util->execCMD("hf 14a raw -pa E1 00 E1 EE");
util->execCMD("hf 14a raw -pa 85 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 18 47"); util->execCMD("hf 14a raw -pa 85 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 18 47");
util->execCMD("hf 14a raw 52"); util->execCMD("hf 14a raw -a 52");
}
else if(util->getClientType() == Util::CLIENTTYPE_ICEMAN)
{
util->execCMD("hf 14a raw -ak -b 7 40");
util->execCMD("hf 14a raw -ak 43");
util->execCMD("hf 14a raw -ak E0 00 39 F7");
util->execCMD("hf 14a raw -ak E1 00 E1 EE");
util->execCMD("hf 14a raw -ak 85 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 18 47");
util->execCMD("hf 14a raw -a 52");
}
} }
void Mifare::wipeE() void Mifare::wipeE()

@ -18,6 +18,14 @@ MF_UID_parameterDialog::~MF_UID_parameterDialog()
void MF_UID_parameterDialog::on_buttonBox_accepted() void MF_UID_parameterDialog::on_buttonBox_accepted()
{ {
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
emit sendCMD("hf mf csetuid "
+ ui->UIDLineEdit->text()
+ " "
+ ui->ATQALineEdit->text()
+ " "
+ ui->SAKLineEdit->text());
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN) // same format in v4.9237
emit sendCMD("hf mf csetuid " emit sendCMD("hf mf csetuid "
+ ui->UIDLineEdit->text() + ui->UIDLineEdit->text()
+ " " + " "

@ -2,6 +2,7 @@
#define MF_UID_PARAMETERDIALOG_H #define MF_UID_PARAMETERDIALOG_H
#include <QDialog> #include <QDialog>
#include "common/util.h"
namespace Ui namespace Ui
{ {

Loading…
Cancel
Save