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