Support hardnested(), darkside(), readblk(),

readsec() in latest Iceman repo
pull/14/head
wh201906 4 years ago
parent 6baa09221e
commit 24a6e1869b

@ -1,11 +1,12 @@
#include "util.h"
Util::ClientType Util::clientType = CLIENTTYPE_OFFICIAL;
Util::Util(QObject *parent) : QObject(parent)
{
isRequiringOutput = false;
requiredOutput = new QString();
timeStamp = QTime::currentTime();
this->clientType = CLIENTTYPE_OFFICIAL;
qRegisterMetaType<Util::ClientType>("Util::ClientType");
}
@ -79,14 +80,15 @@ void Util::delay(unsigned int msec)
while(QTime::currentTime() < timer)
QApplication::processEvents(QEventLoop::AllEvents, 100);
}
Util::ClientType Util::getClientType()
{
return this->clientType;
return Util::clientType;
}
void Util::setClientType(Util::ClientType clientType)
{
this->clientType = clientType;
Util::clientType = clientType;
}
void Util::setRunningState(bool st)

@ -52,12 +52,12 @@ public:
void execCMD(const QString& cmd);
QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
void delay(unsigned int msec);
ClientType getClientType();
static ClientType getClientType();
static const int rawTabIndex = 1;
static bool chooseLanguage(QSettings *guiSettings, QMainWindow *window);
public slots:
void processOutput(const QString& output);
void setClientType(Util::ClientType clientType);
static void setClientType(Util::ClientType clientType);
void setRunningState(bool st);
private:
@ -65,7 +65,7 @@ private:
bool isRunning;
QString* requiredOutput;
QTime timeStamp;
ClientType clientType;
static ClientType clientType;
signals:
void refreshOutput(const QString& output);
void write(QString data); // connected to PM3Process::write(QString data);

@ -989,56 +989,56 @@ or &quot;-p &lt;port&gt; -f&quot;</source>
<context>
<name>Mifare</name>
<message>
<location filename="../module/mifare.cpp" line="613"/>
<location filename="../module/mifare.cpp" line="617"/>
<source>Success!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="225"/>
<location filename="../module/mifare.cpp" line="613"/>
<location filename="../module/mifare.cpp" line="229"/>
<location filename="../module/mifare.cpp" line="617"/>
<location filename="../module/mifare.cpp" line="641"/>
<location filename="../module/mifare.cpp" line="680"/>
<location filename="../module/mifare.cpp" line="693"/>
<location filename="../module/mifare.cpp" line="739"/>
<location filename="../module/mifare.cpp" line="621"/>
<location filename="../module/mifare.cpp" line="645"/>
<location filename="../module/mifare.cpp" line="684"/>
<location filename="../module/mifare.cpp" line="697"/>
<location filename="../module/mifare.cpp" line="743"/>
<source>Info</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="225"/>
<location filename="../module/mifare.cpp" line="229"/>
<source>Plz provide at least one known key</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="464"/>
<location filename="../module/mifare.cpp" line="617"/>
<location filename="../module/mifare.cpp" line="468"/>
<location filename="../module/mifare.cpp" line="621"/>
<source>Failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="642"/>
<location filename="../module/mifare.cpp" line="646"/>
<source>The Access Bits is invalid!
It could make the whole sector blocked irreversibly!
Continue to write?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="680"/>
<location filename="../module/mifare.cpp" line="684"/>
<source>Successful!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="693"/>
<location filename="../module/mifare.cpp" line="697"/>
<source>Failed to write to these blocks:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="697"/>
<location filename="../module/mifare.cpp" line="701"/>
<source>Select them?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="739"/>
<location filename="../module/mifare.cpp" line="743"/>
<source>Failed to read card.</source>
<translation type="unfinished"></translation>
</message>

@ -532,13 +532,13 @@ It could make the whole sector blocked irreversibly!</source>
<location filename="../ui/mainwindow.ui" line="757"/>
<location filename="../ui/mainwindow.ui" line="891"/>
<source>Read One</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../ui/mainwindow.ui" line="770"/>
<location filename="../ui/mainwindow.ui" line="904"/>
<source>Write One</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../ui/mainwindow.ui" line="783"/>
@ -997,34 +997,34 @@ or &quot;-p &lt;port&gt; -f&quot;</source>
<context>
<name>Mifare</name>
<message>
<location filename="../module/mifare.cpp" line="613"/>
<location filename="../module/mifare.cpp" line="617"/>
<source>Success!</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="225"/>
<location filename="../module/mifare.cpp" line="613"/>
<location filename="../module/mifare.cpp" line="229"/>
<location filename="../module/mifare.cpp" line="617"/>
<location filename="../module/mifare.cpp" line="641"/>
<location filename="../module/mifare.cpp" line="680"/>
<location filename="../module/mifare.cpp" line="693"/>
<location filename="../module/mifare.cpp" line="739"/>
<location filename="../module/mifare.cpp" line="621"/>
<location filename="../module/mifare.cpp" line="645"/>
<location filename="../module/mifare.cpp" line="684"/>
<location filename="../module/mifare.cpp" line="697"/>
<location filename="../module/mifare.cpp" line="743"/>
<source>Info</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="225"/>
<location filename="../module/mifare.cpp" line="229"/>
<source>Plz provide at least one known key</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="464"/>
<location filename="../module/mifare.cpp" line="617"/>
<location filename="../module/mifare.cpp" line="468"/>
<location filename="../module/mifare.cpp" line="621"/>
<source>Failed!</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="642"/>
<location filename="../module/mifare.cpp" line="646"/>
<source>The Access Bits is invalid!
It could make the whole sector blocked irreversibly!
Continue to write?</source>
@ -1033,22 +1033,22 @@ Continue to write?</source>
</translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="680"/>
<location filename="../module/mifare.cpp" line="684"/>
<source>Successful!</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="693"/>
<location filename="../module/mifare.cpp" line="697"/>
<source>Failed to write to these blocks:</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="697"/>
<location filename="../module/mifare.cpp" line="701"/>
<source>Select them?</source>
<translation></translation>
</message>
<message>
<location filename="../module/mifare.cpp" line="739"/>
<location filename="../module/mifare.cpp" line="743"/>
<source>Failed to read card.</source>
<translation></translation>
</message>

@ -298,6 +298,7 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
{
QString data;
QString result;
QRegularExpressionMatch currMatch;
bool isTrailerBlock = (blockId < 128 && ((blockId + 1) % 4 == 0)) || ((blockId + 1) % 16 == 0);
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL || util->getClientType() == Util::CLIENTTYPE_ICEMAN)
@ -317,9 +318,10 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
+ " "
+ key,
waitTime);
if(result.indexOf("isOk:01") != -1)
currMatch = dataPattern->match(result);
if(currMatch.hasMatch())
{
data = dataPattern->match(result).captured().toUpper();
data = currMatch.captured().toUpper();
data.remove(" ");
// when the target block is a key block and the given key type is KeyA, try to check whether the KeyB is valid(by Access Bits)
// if the given key type is KeyB, it will never get the KeyA from the key block
@ -347,15 +349,19 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
"hf mf cgetblk "
+ QString::number(blockId),
waitTime);
if(result.indexOf("Chinese magic") != -1)
currMatch = dataPattern->match(result);
if(currMatch.hasMatch())
{
data = dataPattern->match(result).captured().toUpper();
data = currMatch.captured().toUpper();
data.remove(" ");
}
else
data = "";
}
else if(targetType == TARGET_EMULATOR)
}
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL)
{
if(targetType == TARGET_EMULATOR)
{
result = util->execCMDWithOutput(
"hf mf eget "
@ -365,6 +371,18 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
data.remove(" ");
}
}
else if(util->getClientType() == Util::CLIENTTYPE_ICEMAN)
{
if(targetType == TARGET_EMULATOR)
{
result = util->execCMDWithOutput(
"hf mf egetblk "
+ QString::number(blockId),
150);
data = dataPattern->match(result).captured().toUpper();
data.remove(" ");
}
}
return data;
}
@ -373,7 +391,7 @@ QStringList Mifare::_readsec(int sectorId, KeyType keyType, const QString& key,
QStringList data;
QString result, tmp;
QRegularExpressionMatch reMatch;
int offset = -1;
int offset = -1; // for targetType == TARGET_EMULATOR
for(int i = 0; i < cardType.blk[sectorId]; i++)
{
@ -397,7 +415,7 @@ QStringList Mifare::_readsec(int sectorId, KeyType keyType, const QString& key,
+ " "
+ key,
waitTime);
offset = result.indexOf("isOk:01");
offset = result.indexOf("isOk:01"); // find successful flag
}
else if(targetType == TARGET_UID)
{
@ -405,7 +423,7 @@ QStringList Mifare::_readsec(int sectorId, KeyType keyType, const QString& key,
"hf mf cgetsc "
+ QString::number(sectorId),
waitTime);
offset = result.indexOf("Chinese magic");
offset = result.indexOf("error") == -1 ? 0 : -1; // find failed flag
}
if(offset != -1)
{
@ -424,7 +442,7 @@ QStringList Mifare::_readsec(int sectorId, KeyType keyType, const QString& key,
}
// if failed, try to read them seperately.
// (when one of the block cannot be read, the rdsc will return nothing, so you need to read the rest of blocks manually)
else if(targetType != TARGET_UID) // if the targetType is Chinese Magic Card, then the result implies the backdoor command is invalid.
else if(targetType == TARGET_UID || targetType == TARGET_EMULATOR) // if the targetType is Chinese Magic Card, then the result implies the backdoor command is invalid.
{
for(int i = 0; i < cardType.blk[sectorId]; i++)
data[i] = _readblk(cardType.blks[sectorId] + i, keyType, key, targetType, waitTime);

@ -21,6 +21,18 @@ MF_Attack_hardnestedDialog::~MF_Attack_hardnestedDialog()
void MF_Attack_hardnestedDialog::on_buttonBox_accepted()
{
if(Util::getClientType() == Util::CLIENTTYPE_OFFICIAL)
emit sendCMD("hf mf hardnested "
+ ui->knownKeySectorBox->currentText()
+ " "
+ ui->knownKeyTypeBox->currentText()
+ " "
+ ui->knownKeyBox->text()
+ " "
+ ui->targetKeySectorBox->currentText()
+ " "
+ ui->targetKeyTypeBox->currentText());
else if(Util::getClientType() == Util::CLIENTTYPE_ICEMAN) // same format in v4.9237
emit sendCMD("hf mf hardnested "
+ ui->knownKeySectorBox->currentText()
+ " "

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

Loading…
Cancel
Save