mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-03-14 18:44:41 +08:00
Replace QRegExp with QRegularExpression(Uncompleted)
This commit is contained in:
parent
ef6ebea568
commit
eb5fa7ec9a
@ -17,6 +17,7 @@ PM3Process::PM3Process(QThread* thread, QObject* parent): QProcess(parent)
|
|||||||
void PM3Process::connectPM3(const QString path, const QString port)
|
void PM3Process::connectPM3(const QString path, const QString port)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
Util::ClientType clientType = Util::CLIENTTYPE_OFFICIAL;
|
||||||
setRequiringOutput(true);
|
setRequiringOutput(true);
|
||||||
|
|
||||||
// using "-f" option to make the client output flushed after every print.
|
// using "-f" option to make the client output flushed after every print.
|
||||||
@ -28,7 +29,7 @@ void PM3Process::connectPM3(const QString path, const QString port)
|
|||||||
result = *requiredOutput;
|
result = *requiredOutput;
|
||||||
if(result.indexOf("[=]") != -1)
|
if(result.indexOf("[=]") != -1)
|
||||||
{
|
{
|
||||||
emit changeClientType(Util::CLIENTTYPE_ICEMAN);
|
clientType = Util::CLIENTTYPE_ICEMAN;
|
||||||
setRequiringOutput(true);
|
setRequiringOutput(true);
|
||||||
write("hw version\r\n");
|
write("hw version\r\n");
|
||||||
waitForReadyRead(1000);
|
waitForReadyRead(1000);
|
||||||
@ -37,6 +38,7 @@ void PM3Process::connectPM3(const QString path, const QString port)
|
|||||||
}
|
}
|
||||||
if(result.indexOf("os: ") != -1) // make sure the PM3 is connected
|
if(result.indexOf("os: ") != -1) // make sure the PM3 is connected
|
||||||
{
|
{
|
||||||
|
emit changeClientType(clientType);
|
||||||
result = result.mid(result.indexOf("os: "));
|
result = result.mid(result.indexOf("os: "));
|
||||||
result = result.left(result.indexOf("\r\n"));
|
result = result.left(result.indexOf("\r\n"));
|
||||||
result = result.mid(3, result.lastIndexOf(" ") - 3);
|
result = result.mid(3, result.lastIndexOf(" ") - 3);
|
||||||
|
@ -9,24 +9,25 @@ Mifare::Mifare(Ui::MainWindow *ui, Util *addr, QWidget *parent): QObject(parent)
|
|||||||
keyAList = new QStringList();
|
keyAList = new QStringList();
|
||||||
keyBList = new QStringList();
|
keyBList = new QStringList();
|
||||||
dataList = new QStringList();
|
dataList = new QStringList();
|
||||||
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 QRegExp("([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}");
|
dataPattern = new QRegExp("([0-9a-fA-F]{2} ){15}[0-9a-fA-F]{2}");
|
||||||
chkKeyPattern = new QRegExp("\\|\\d{3}\\|.+\\|.+\\|");
|
keyPattern_res = new QRegularExpression("\\|\\d{3}\\|.+?\\|.+?\\|.+?\\|.+?\\|");
|
||||||
nestedKeyPattern = new QRegExp("\\|\\d{3}\\|.+\\|.+\\|.+\\|.+\\|");
|
keyPattern = new QRegularExpression("\\|\\d{3}\\|.+?\\|.+?\\|");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Mifare::info(bool isRequiringOutput)
|
QString Mifare::info(bool isRequiringOutput)
|
||||||
|
{
|
||||||
|
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL || util->getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||||
{
|
{
|
||||||
if(isRequiringOutput)
|
if(isRequiringOutput)
|
||||||
{
|
{
|
||||||
QString result = util->execCMDWithOutput("hf 14a info", 500);
|
QString result = util->execCMDWithOutput("hf 14a info", 500);
|
||||||
qDebug() << result << result.indexOf(QRegExp(ui->MF_RW_dataEdit->text()), 0);
|
result.replace("UID :", "|||");
|
||||||
result.replace("UID :", "|");
|
result.replace("ATQA :", "|||");
|
||||||
result.replace("ATQA :", "|");
|
result.replace("SAK :", "|||");
|
||||||
result.replace("SAK :", "|");
|
result.replace("TYPE :", "|||");
|
||||||
result.replace("TYPE :", "|");
|
QStringList lis = result.split("|||");
|
||||||
QStringList lis = result.split("|");
|
|
||||||
if(lis.length() > 4)
|
if(lis.length() > 4)
|
||||||
{
|
{
|
||||||
qDebug() << lis[1] + lis[2] + lis[3];
|
qDebug() << lis[1] + lis[2] + lis[3];
|
||||||
@ -42,9 +43,11 @@ QString Mifare::info(bool isRequiringOutput)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Mifare::chk()
|
void Mifare::chk()
|
||||||
{
|
{
|
||||||
|
QRegularExpressionMatch reMatch;
|
||||||
QString result = util->execCMDWithOutput(
|
QString result = util->execCMDWithOutput(
|
||||||
"hf mf chk *"
|
"hf mf chk *"
|
||||||
+ QString::number(cardType.type)
|
+ QString::number(cardType.type)
|
||||||
@ -53,21 +56,53 @@ void Mifare::chk()
|
|||||||
qDebug() << result;
|
qDebug() << result;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
QString tmp, tmp2;
|
QString data;
|
||||||
|
if(util->getClientType() == Util::CLIENTTYPE_OFFICIAL)
|
||||||
|
{
|
||||||
for(int i = 0; i < cardType.sector_size; i++)
|
for(int i = 0; i < cardType.sector_size; i++)
|
||||||
{
|
{
|
||||||
offset = chkKeyPattern->indexIn(result, offset);
|
reMatch = keyPattern->match(result, offset);
|
||||||
// offset = result.indexOf(*chkKeyPattern, offset);
|
offset = reMatch.capturedStart();
|
||||||
tmp = result.mid(offset, 39).toUpper();
|
if(reMatch.hasMatch())
|
||||||
offset += 39;
|
{
|
||||||
qDebug() << tmp << offset;
|
data = reMatch.captured().toUpper();
|
||||||
tmp2 = tmp.mid(7, 12).trimmed();
|
offset += data.length();
|
||||||
if(tmp2 != "?")
|
QStringList cells = data.remove(" ").split("|");
|
||||||
keyAList->replace(i, tmp2);
|
if(!cells.at(2).contains("?"))
|
||||||
tmp2 = tmp.mid(24, 12).trimmed();
|
{
|
||||||
if(tmp2 != "?")
|
keyAList->replace(i, cells.at(2));
|
||||||
keyBList->replace(i, tmp2);
|
|
||||||
}
|
}
|
||||||
|
if(!cells.at(3).contains("?"))
|
||||||
|
{
|
||||||
|
keyBList->replace(i, cells.at(3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(util->getClientType() == Util::CLIENTTYPE_ICEMAN)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < cardType.sector_size; i++)
|
||||||
|
{
|
||||||
|
reMatch = keyPattern_res->match(result, offset);
|
||||||
|
offset = reMatch.capturedStart();
|
||||||
|
if(reMatch.hasMatch())
|
||||||
|
{
|
||||||
|
data = reMatch.captured().toUpper();
|
||||||
|
offset += data.length();
|
||||||
|
QStringList cells = data.remove(" ").split("|");
|
||||||
|
if(cells.at(3) == "1")
|
||||||
|
{
|
||||||
|
keyAList->replace(i, cells.at(2));
|
||||||
|
}
|
||||||
|
if(cells.at(5) == "1")
|
||||||
|
{
|
||||||
|
keyBList->replace(i, cells.at(4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
data_syncWithKeyWidget();
|
data_syncWithKeyWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +117,7 @@ void Mifare::nested()
|
|||||||
QString tmp;
|
QString tmp;
|
||||||
for(int i = 0; i < cardType.sector_size; i++)
|
for(int i = 0; i < cardType.sector_size; i++)
|
||||||
{
|
{
|
||||||
offset = nestedKeyPattern->indexIn(result, offset);
|
// offset = nestedKeyPattern->indexIn(result, offset);
|
||||||
// offset = result.indexOf(*nestedKeyPattern, offset);
|
// offset = result.indexOf(*nestedKeyPattern, offset);
|
||||||
tmp = result.mid(offset, 47).toUpper();
|
tmp = result.mid(offset, 47).toUpper();
|
||||||
offset += 47;
|
offset += 47;
|
||||||
|
@ -135,8 +135,8 @@ private:
|
|||||||
QStringList* keyBList;
|
QStringList* keyBList;
|
||||||
QStringList* dataList;
|
QStringList* dataList;
|
||||||
QRegExp* dataPattern;
|
QRegExp* dataPattern;
|
||||||
QRegExp* chkKeyPattern;
|
QRegularExpression* keyPattern_res;
|
||||||
QRegExp* nestedKeyPattern;
|
QRegularExpression* keyPattern;
|
||||||
QRegExp* UIDPattern;
|
QRegExp* UIDPattern;
|
||||||
QString bin2text(const QByteArray& buff, int start, int length);
|
QString bin2text(const QByteArray& buff, int start, int length);
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@ MainWindow::MainWindow(QWidget *parent):
|
|||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
// ui->MF_simGroupBox->setVisible(false); // developing...
|
|
||||||
// ui->MF_sniffGroupBox->setVisible(false); // developing...
|
|
||||||
myInfo = new QAction("wh201906", this);
|
myInfo = new QAction("wh201906", this);
|
||||||
connect(myInfo, &QAction::triggered, [ = ]()
|
connect(myInfo, &QAction::triggered, [ = ]()
|
||||||
{
|
{
|
||||||
@ -94,6 +92,7 @@ void MainWindow::onPM3StateChanged(bool st, QString info)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
setStatusBar(PM3VersionBar, "");
|
||||||
setStatusBar(connectStatusBar, tr("Not Connected"));
|
setStatusBar(connectStatusBar, tr("Not Connected"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="PM3_pathEdit">
|
<widget class="QLineEdit" name="PM3_pathEdit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">../pm3/win64/proxmark3</string>
|
<string notr="true">../pm3/iceman-64/win64/proxmark3</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user