mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-03-15 02:54:40 +08:00
Add _readblk() (not tested)
This commit is contained in:
parent
cd122b8959
commit
a77985824c
@ -1,10 +1,11 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
Util::Util(QObject *parent) : QObject(parent)
|
Util::Util(Util::ClientType clientType, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
isRequiringOutput = false;
|
isRequiringOutput = false;
|
||||||
requiredOutput = new QString();
|
requiredOutput = new QString();
|
||||||
timeStamp = QTime::currentTime();
|
timeStamp = QTime::currentTime();
|
||||||
|
this->clientType = clientType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Util::processOutput(QString output)
|
void Util::processOutput(QString output)
|
||||||
@ -50,3 +51,7 @@ void Util::delay(unsigned int msec)
|
|||||||
while(QTime::currentTime() < timer)
|
while(QTime::currentTime() < timer)
|
||||||
QApplication::processEvents(QEventLoop::AllEvents, 100);
|
QApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||||
}
|
}
|
||||||
|
Util::ClientType Util::getClientType()
|
||||||
|
{
|
||||||
|
return this->clientType;
|
||||||
|
}
|
||||||
|
@ -13,11 +13,17 @@ class Util : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Util(QObject *parent = nullptr);
|
enum ClientType
|
||||||
|
{
|
||||||
|
OFFICIAL,
|
||||||
|
ICEMAN,
|
||||||
|
};
|
||||||
|
explicit Util(Util::ClientType clientType, QObject *parent = nullptr);
|
||||||
|
|
||||||
void execCMD(QString cmd);
|
void execCMD(QString cmd);
|
||||||
QString execCMDWithOutput(QString cmd, unsigned long timeout = 2000);
|
QString execCMDWithOutput(QString cmd, unsigned long timeout = 2000);
|
||||||
void delay(unsigned int msec);
|
void delay(unsigned int msec);
|
||||||
|
ClientType getClientType();
|
||||||
public slots:
|
public slots:
|
||||||
void processOutput(QString output);
|
void processOutput(QString output);
|
||||||
|
|
||||||
@ -28,6 +34,7 @@ private:
|
|||||||
signals:
|
signals:
|
||||||
void refreshOutput(const QString& output);
|
void refreshOutput(const QString& output);
|
||||||
void write(QString data);
|
void write(QString data);
|
||||||
|
ClientType clientType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTIL_H
|
#endif // UTIL_H
|
||||||
|
@ -114,6 +114,72 @@ void Mifare::list()
|
|||||||
ui->funcTab->setCurrentIndex(1);
|
ui->funcTab->setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Mifare::_readblk(int blockId, KeyType keyType, QString& key, int waitTime)
|
||||||
|
{
|
||||||
|
QString data;
|
||||||
|
QString result;
|
||||||
|
if(util->getClientType() == Util::OFFICIAL)
|
||||||
|
{
|
||||||
|
result = util->execCMDWithOutput(
|
||||||
|
"hf mf rdbl "
|
||||||
|
+ QString::number(blockId)
|
||||||
|
+ " "
|
||||||
|
+ (char)keyType
|
||||||
|
+ " "
|
||||||
|
+ key,
|
||||||
|
waitTime);
|
||||||
|
if(result.indexOf("isOk:01") != -1)
|
||||||
|
{
|
||||||
|
result = result.mid(dataPattern->indexIn(result), 47).toUpper();
|
||||||
|
if((blockId < 128 && ((blockId + 1) % 4 == 0)) || ((blockId + 1) % 8 == 0)) // process key block
|
||||||
|
{
|
||||||
|
if(keyType == KEY_A)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
result = result.replace(i * 3, 2, key.mid(i * 2, 2));
|
||||||
|
}
|
||||||
|
data = result;
|
||||||
|
QString tmpKey = result.right(18).replace(" ", "");
|
||||||
|
result = util->execCMDWithOutput(
|
||||||
|
"hf mf rdbl "
|
||||||
|
+ QString::number(blockId)
|
||||||
|
+ " B "
|
||||||
|
+ tmpKey,
|
||||||
|
waitTime);
|
||||||
|
if(result.indexOf("isOk:01") == -1)
|
||||||
|
{
|
||||||
|
result = data;
|
||||||
|
result = result.replace(30, 17, "?? ?? ?? ?? ?? ??");
|
||||||
|
data = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
result = result.replace(
|
||||||
|
30 + i * 3,
|
||||||
|
2,
|
||||||
|
key.mid(i * 2, 2));
|
||||||
|
}
|
||||||
|
result = result.replace(0, 18, "?? ?? ?? ?? ?? ?? ");
|
||||||
|
data = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data = "";
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Mifare::read()
|
void Mifare::read()
|
||||||
{
|
{
|
||||||
int waitTime = 300;
|
int waitTime = 300;
|
||||||
|
@ -32,8 +32,8 @@ public:
|
|||||||
|
|
||||||
enum KeyType
|
enum KeyType
|
||||||
{
|
{
|
||||||
KEY_A,
|
KEY_A = 'A',
|
||||||
KEY_B,
|
KEY_B = 'B',
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DataType
|
enum DataType
|
||||||
@ -134,6 +134,8 @@ private:
|
|||||||
QRegExp* nestedKeyPattern;
|
QRegExp* nestedKeyPattern;
|
||||||
QRegExp* UIDPattern;
|
QRegExp* UIDPattern;
|
||||||
QString bin2text(const QByteArray& buff, int start, int length);
|
QString bin2text(const QByteArray& buff, int start, int length);
|
||||||
|
|
||||||
|
QString _readblk(int blockId, KeyType keyType, QString &key, int waitTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MIFARE_H
|
#endif // MIFARE_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user