|
|
@ -126,7 +126,7 @@ void Mifare::chk()
|
|
|
|
QString result;
|
|
|
|
QString result;
|
|
|
|
int offset = 0;
|
|
|
|
int offset = 0;
|
|
|
|
QString data;
|
|
|
|
QString data;
|
|
|
|
QVariantMap config = configMap["chk"].toMap();
|
|
|
|
QVariantMap config = configMap["check"].toMap();
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
int keyAindex = config["key A index"].toInt();
|
|
|
|
int keyAindex = config["key A index"].toInt();
|
|
|
|
int keyBindex = config["key B index"].toInt();
|
|
|
|
int keyBindex = config["key B index"].toInt();
|
|
|
@ -254,10 +254,8 @@ void Mifare::hardnested()
|
|
|
|
|
|
|
|
|
|
|
|
void Mifare::darkside()
|
|
|
|
void Mifare::darkside()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["darkside"].toMap();
|
|
|
|
util->execCMD("hf mf mifare");
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
util->execCMD("hf mf darkside");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -280,7 +278,7 @@ void Mifare::sniff14a()
|
|
|
|
|
|
|
|
|
|
|
|
void Mifare::list()
|
|
|
|
void Mifare::list()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QVariantMap config = configMap["sniff 14a"].toMap();
|
|
|
|
QVariantMap config = configMap["list"].toMap();
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
@ -293,24 +291,22 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
|
|
|
|
QRegularExpressionMatch currMatch;
|
|
|
|
QRegularExpressionMatch currMatch;
|
|
|
|
bool isTrailerBlock = (blockId < 128 && ((blockId + 1) % 4 == 0)) || ((blockId + 1) % 16 == 0);
|
|
|
|
bool isTrailerBlock = (blockId < 128 && ((blockId + 1) % 4 == 0)) || ((blockId + 1) % 16 == 0);
|
|
|
|
|
|
|
|
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL || Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(targetType == TARGET_MIFARE)
|
|
|
|
if(targetType == TARGET_MIFARE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!data_isKeyValid(key))
|
|
|
|
if(!data_isKeyValid(key))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariantMap config = configMap["normal read block"].toMap();
|
|
|
|
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
|
|
|
|
QRegularExpression dataPattern = QRegularExpression(config["data pattern"].toString());
|
|
|
|
|
|
|
|
cmd.replace("<block>", QString::number(blockId));
|
|
|
|
|
|
|
|
cmd.replace("<key type>", config["key type"].toMap()[QString((char)keyType)].toString());
|
|
|
|
|
|
|
|
cmd.replace("<key>", key);
|
|
|
|
// use the given key type to read the target block
|
|
|
|
// use the given key type to read the target block
|
|
|
|
result = util->execCMDWithOutput(
|
|
|
|
result = util->execCMDWithOutput(cmd, waitTime);
|
|
|
|
"hf mf rdbl "
|
|
|
|
|
|
|
|
+ QString::number(blockId)
|
|
|
|
currMatch = dataPattern.match(result);
|
|
|
|
+ " "
|
|
|
|
|
|
|
|
+ (char)keyType
|
|
|
|
|
|
|
|
+ " "
|
|
|
|
|
|
|
|
+ key,
|
|
|
|
|
|
|
|
waitTime);
|
|
|
|
|
|
|
|
currMatch = dataPattern->match(result);
|
|
|
|
|
|
|
|
if(currMatch.hasMatch())
|
|
|
|
if(currMatch.hasMatch())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data = currMatch.captured().toUpper();
|
|
|
|
data = currMatch.captured().toUpper();
|
|
|
@ -337,11 +333,12 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(targetType == TARGET_UID)
|
|
|
|
else if(targetType == TARGET_UID)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = util->execCMDWithOutput(
|
|
|
|
QVariantMap config = configMap["Magic Card read block"].toMap();
|
|
|
|
"hf mf cgetblk "
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
+ QString::number(blockId),
|
|
|
|
QRegularExpression dataPattern = QRegularExpression(config["data pattern"].toString());
|
|
|
|
waitTime);
|
|
|
|
cmd.replace("<block>", QString::number(blockId));
|
|
|
|
currMatch = dataPattern->match(result);
|
|
|
|
result = util->execCMDWithOutput(cmd, waitTime);
|
|
|
|
|
|
|
|
currMatch = dataPattern.match(result);
|
|
|
|
if(currMatch.hasMatch())
|
|
|
|
if(currMatch.hasMatch())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data = currMatch.captured().toUpper();
|
|
|
|
data = currMatch.captured().toUpper();
|
|
|
@ -350,31 +347,17 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
|
|
|
|
else
|
|
|
|
else
|
|
|
|
data = "";
|
|
|
|
data = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(targetType == TARGET_EMULATOR)
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(targetType == TARGET_EMULATOR)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
result = util->execCMDWithOutput(
|
|
|
|
|
|
|
|
"hf mf eget "
|
|
|
|
|
|
|
|
+ QString::number(blockId),
|
|
|
|
|
|
|
|
150);
|
|
|
|
|
|
|
|
data = dataPattern->match(result).captured().toUpper();
|
|
|
|
|
|
|
|
data.remove(" ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(targetType == TARGET_EMULATOR)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = util->execCMDWithOutput(
|
|
|
|
QVariantMap config = configMap["emulator read block"].toMap();
|
|
|
|
"hf mf egetblk "
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
+ QString::number(blockId),
|
|
|
|
QRegularExpression dataPattern = QRegularExpression(config["data pattern"].toString());
|
|
|
|
150);
|
|
|
|
cmd.replace("<block>", QString::number(blockId));
|
|
|
|
data = dataPattern->match(result).captured().toUpper();
|
|
|
|
result = util->execCMDWithOutput(cmd, 150);
|
|
|
|
|
|
|
|
data = dataPattern.match(result).captured().toUpper();
|
|
|
|
data.remove(" ");
|
|
|
|
data.remove(" ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -761,7 +744,7 @@ void Mifare::restore()
|
|
|
|
|
|
|
|
|
|
|
|
void Mifare::wipeC()
|
|
|
|
void Mifare::wipeC()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QVariantMap config = configMap["wipe Magic Card"].toMap();
|
|
|
|
QVariantMap config = configMap["Magic Card wipe"].toMap();
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
if(cmd.contains("<card type>"))
|
|
|
|
if(cmd.contains("<card type>"))
|
|
|
|
cmd.replace("<card type>", config["card type"].toMap()[cardType.typeText].toString());
|
|
|
|
cmd.replace("<card type>", config["card type"].toMap()[cardType.typeText].toString());
|
|
|
@ -810,7 +793,7 @@ void Mifare::lockC()
|
|
|
|
|
|
|
|
|
|
|
|
void Mifare::wipeE()
|
|
|
|
void Mifare::wipeE()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QVariantMap config = configMap["wipe emulator"].toMap();
|
|
|
|
QVariantMap config = configMap["emulator wipe"].toMap();
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
util->execCMD(config["cmd"].toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -824,12 +807,17 @@ void Mifare::simulate()
|
|
|
|
|
|
|
|
|
|
|
|
void Mifare::loadSniff(const QString& file)
|
|
|
|
void Mifare::loadSniff(const QString& file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["load sniff"].toMap();
|
|
|
|
util->execCMD("hf list mf -l " + file);
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
cmd.replace("<filename>", file);
|
|
|
|
|
|
|
|
if(config.contains("show cmd"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(util->execCMDWithOutput("trace load -f " + file, Util::ReturnTrigger({"loaded"})) != "")
|
|
|
|
if(util->execCMDWithOutput(cmd, Util::ReturnTrigger({"loaded"})) != "")
|
|
|
|
util->execCMD("trace list -t mf");
|
|
|
|
util->execCMD(config["show cmd"].toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
util->execCMD(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
@ -837,10 +825,10 @@ void Mifare::loadSniff(const QString& file)
|
|
|
|
|
|
|
|
|
|
|
|
void Mifare::saveSniff(const QString& file)
|
|
|
|
void Mifare::saveSniff(const QString& file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
|
|
|
QVariantMap config = configMap["save sniff"].toMap();
|
|
|
|
util->execCMD("hf list mf -s " + file);
|
|
|
|
QString cmd = config["cmd"].toString();
|
|
|
|
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN)
|
|
|
|
cmd.replace("<filename>", file);
|
|
|
|
util->execCMD("trace save -f " + file);
|
|
|
|
util->execCMD(cmd);
|
|
|
|
|
|
|
|
|
|
|
|
Util::gotoRawTab();
|
|
|
|
Util::gotoRawTab();
|
|
|
|
}
|
|
|
|
}
|
|
|
|