mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-02-16 22:21:30 +08:00
Add _readblk() (not tested)
This commit is contained in:
parent
cd122b8959
commit
a77985824c
@ -1,10 +1,11 @@
|
||||
#include "util.h"
|
||||
|
||||
Util::Util(QObject *parent) : QObject(parent)
|
||||
Util::Util(Util::ClientType clientType, QObject *parent) : QObject(parent)
|
||||
{
|
||||
isRequiringOutput = false;
|
||||
requiredOutput = new QString();
|
||||
timeStamp = QTime::currentTime();
|
||||
this->clientType = clientType;
|
||||
}
|
||||
|
||||
void Util::processOutput(QString output)
|
||||
@ -31,7 +32,7 @@ QString Util::execCMDWithOutput(QString cmd, unsigned long timeout)
|
||||
isRequiringOutput = true;
|
||||
requiredOutput->clear();
|
||||
execCMD(cmd);
|
||||
while( QTime::currentTime() < targetTime)
|
||||
while(QTime::currentTime() < targetTime)
|
||||
{
|
||||
QApplication::processEvents();
|
||||
if(timeStamp > currTime)
|
||||
@ -47,6 +48,10 @@ QString Util::execCMDWithOutput(QString cmd, unsigned long timeout)
|
||||
void Util::delay(unsigned int msec)
|
||||
{
|
||||
QTime timer = QTime::currentTime().addMSecs(msec);
|
||||
while( QTime::currentTime() < timer )
|
||||
while(QTime::currentTime() < timer)
|
||||
QApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
}
|
||||
Util::ClientType Util::getClientType()
|
||||
{
|
||||
return this->clientType;
|
||||
}
|
||||
|
@ -13,11 +13,17 @@ class Util : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Util(QObject *parent = nullptr);
|
||||
enum ClientType
|
||||
{
|
||||
OFFICIAL,
|
||||
ICEMAN,
|
||||
};
|
||||
explicit Util(Util::ClientType clientType, QObject *parent = nullptr);
|
||||
|
||||
void execCMD(QString cmd);
|
||||
QString execCMDWithOutput(QString cmd, unsigned long timeout = 2000);
|
||||
void delay(unsigned int msec);
|
||||
ClientType getClientType();
|
||||
public slots:
|
||||
void processOutput(QString output);
|
||||
|
||||
@ -28,6 +34,7 @@ private:
|
||||
signals:
|
||||
void refreshOutput(const QString& output);
|
||||
void write(QString data);
|
||||
ClientType clientType;
|
||||
};
|
||||
|
||||
#endif // UTIL_H
|
||||
|
@ -114,6 +114,72 @@ void Mifare::list()
|
||||
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()
|
||||
{
|
||||
int waitTime = 300;
|
||||
|
@ -32,8 +32,8 @@ public:
|
||||
|
||||
enum KeyType
|
||||
{
|
||||
KEY_A,
|
||||
KEY_B,
|
||||
KEY_A = 'A',
|
||||
KEY_B = 'B',
|
||||
};
|
||||
|
||||
enum DataType
|
||||
@ -87,7 +87,7 @@ public:
|
||||
|
||||
void data_clearData();
|
||||
void data_clearKey();
|
||||
bool data_isKeyValid(const QString &key);
|
||||
bool data_isKeyValid(const QString& key);
|
||||
Mifare::DataType data_isDataValid(QString data);
|
||||
void data_syncWithDataWidget(bool syncAll = true, int block = 0);
|
||||
void data_syncWithKeyWidget(bool syncAll = true, int sector = 0, KeyType keyType = KEY_A);
|
||||
@ -102,15 +102,15 @@ public:
|
||||
void wipeC();
|
||||
void setParameterC();
|
||||
|
||||
bool data_loadDataFile(const QString &filename);
|
||||
bool data_loadKeyFile(const QString &filename);
|
||||
bool data_loadDataFile(const QString& filename);
|
||||
bool data_loadKeyFile(const QString& filename);
|
||||
bool data_saveDataFile(const QString& filename, bool isBin);
|
||||
bool data_saveKeyFile(const QString &filename, bool isBin);
|
||||
bool data_saveKeyFile(const QString& filename, bool isBin);
|
||||
void data_key2Data();
|
||||
void data_data2Key();
|
||||
|
||||
void data_setData(int block, const QString &data);
|
||||
void data_setKey(int sector, KeyType keyType, const QString &key);
|
||||
void data_setData(int block, const QString& data);
|
||||
void data_setKey(int sector, KeyType keyType, const QString& key);
|
||||
void lockC();
|
||||
void writeAllE();
|
||||
void readAllE();
|
||||
@ -133,7 +133,9 @@ private:
|
||||
QRegExp* chkKeyPattern;
|
||||
QRegExp* nestedKeyPattern;
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user