Merge branch 'dev' into master

pull/13/head
wh201906 4 years ago committed by GitHub
commit bf9b3fb076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,6 +16,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \ SOURCES += \
common/myeventfilter.cpp \
main.cpp \ main.cpp \
common/pm3process.cpp \ common/pm3process.cpp \
common/util.cpp \ common/util.cpp \
@ -27,6 +28,7 @@ SOURCES += \
ui/mf_attack_hardnesteddialog.cpp \ ui/mf_attack_hardnesteddialog.cpp \
HEADERS += \ HEADERS += \
common/myeventfilter.h \
common/pm3process.h \ common/pm3process.h \
common/util.h \ common/util.h \
module/mifare.h \ module/mifare.h \

@ -25,7 +25,7 @@ A GUI for [Proxmark3](https://github.com/Proxmark/proxmark3) client
## Preview ## Preview
![preview](README/img/preview.png) ![preview](README/img/preview.png)
more previews [here](README/doc/previews.md) [more previews](README/doc/previews.md)
*** ***

@ -0,0 +1,13 @@
#include "myeventfilter.h"
MyEventFilter::MyEventFilter(QEvent::Type filter)
{
targetEventType = filter;
}
bool MyEventFilter::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == targetEventType)
emit eventHappened(obj, *event);
return QObject::eventFilter(obj, event);
}

@ -0,0 +1,22 @@
#ifndef MYEVENTFILTER_H
#define MYEVENTFILTER_H
#include <QObject>
#include <QKeyEvent>
class MyEventFilter : public QObject
{
Q_OBJECT
public:
explicit MyEventFilter(QEvent::Type filter);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
signals:
void eventHappened(QObject* obj_addr, QEvent& event);
private:
QEvent::Type targetEventType;
};
#endif // MYEVENTFILTER_H

@ -14,7 +14,7 @@ PM3Process::PM3Process(QThread* thread, QObject* parent): QProcess(parent)
connect(this, &PM3Process::readyRead, this, &PM3Process::onReadyRead); connect(this, &PM3Process::readyRead, this, &PM3Process::onReadyRead);
} }
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; Util::ClientType clientType = Util::CLIENTTYPE_OFFICIAL;
@ -93,7 +93,6 @@ void PM3Process::testThread()
qDebug() << "PM3:" << QThread::currentThread(); qDebug() << "PM3:" << QThread::currentThread();
} }
qint64 PM3Process::write(QString data) qint64 PM3Process::write(QString data)
{ {
return QProcess::write(data.toLatin1()); return QProcess::write(data.toLatin1());

@ -21,8 +21,8 @@ public:
void testThread(); void testThread();
public slots: public slots:
void connectPM3(const QString path, const QString port); void connectPM3(const QString& path, const QString& port);
void setSerialListener(const QString &name, bool state); void setSerialListener(const QString& name, bool state);
qint64 write(QString data); qint64 write(QString data);
private slots: private slots:
void onTimeout(); void onTimeout();
@ -34,8 +34,8 @@ private:
QTimer* serialListener; QTimer* serialListener;
QSerialPortInfo* portInfo; QSerialPortInfo* portInfo;
signals: signals:
void PM3StatedChanged(bool st, QString info = ""); void PM3StatedChanged(bool st, const QString& info = "");
void newOutput(QString output); void newOutput(const QString& output);
void changeClientType(Util::ClientType); void changeClientType(Util::ClientType);
}; };

@ -9,7 +9,7 @@ Util::Util(QObject *parent) : QObject(parent)
qRegisterMetaType<Util::ClientType>("Util::ClientType"); qRegisterMetaType<Util::ClientType>("Util::ClientType");
} }
void Util::processOutput(QString output) void Util::processOutput(const QString& output)
{ {
// qDebug() << "Util::processOutput:" << output; // qDebug() << "Util::processOutput:" << output;
if(isRequiringOutput) if(isRequiringOutput)
@ -20,26 +20,45 @@ void Util::processOutput(QString output)
emit refreshOutput(output); emit refreshOutput(output);
} }
void Util::execCMD(QString cmd) void Util::execCMD(const QString& cmd)
{ {
qDebug() << cmd; qDebug() << cmd;
if(isRunning)
emit write(cmd + "\r\n"); emit write(cmd + "\r\n");
} }
QString Util::execCMDWithOutput(QString cmd, unsigned long waitTime) QString Util::execCMDWithOutput(const QString& cmd, ReturnTrigger trigger)
{ {
bool isResultFound = false;
QRegularExpression re;
re.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
if(!isRunning)
return "";
QTime currTime = QTime::currentTime(); QTime currTime = QTime::currentTime();
QTime targetTime = QTime::currentTime().addMSecs(waitTime); QTime targetTime = QTime::currentTime().addMSecs(trigger.waitTime);
isRequiringOutput = true; isRequiringOutput = true;
requiredOutput->clear(); requiredOutput->clear();
execCMD(cmd); execCMD(cmd);
while(QTime::currentTime() < targetTime) while(QTime::currentTime() < targetTime)
{ {
QApplication::processEvents(); QApplication::processEvents();
for(QString otpt : trigger.expectedOutputs)
{
re.setPattern(otpt);
isResultFound = re.match(*requiredOutput).hasMatch();
if(requiredOutput->contains(otpt))
break;
}
if(isResultFound)
{
delay(200);
break;
}
if(timeStamp > currTime) if(timeStamp > currTime)
{ {
currTime = timeStamp; currTime = timeStamp;
targetTime = timeStamp.addMSecs(waitTime); targetTime = timeStamp.addMSecs(trigger.waitTime);
} }
} }
isRequiringOutput = false; isRequiringOutput = false;
@ -61,3 +80,8 @@ void Util::setClientType(Util::ClientType clientType)
{ {
this->clientType = clientType; this->clientType = clientType;
} }
void Util::setRunningState(bool st)
{
this->isRunning = st;
}

@ -9,6 +9,7 @@
#include <QTime> #include <QTime>
#include <QTimer> #include <QTimer>
#include <QMetaType> #include <QMetaType>
#include <QRegularExpression>
class Util : public QObject class Util : public QObject
{ {
@ -20,26 +21,49 @@ public:
CLIENTTYPE_ICEMAN, CLIENTTYPE_ICEMAN,
}; };
struct ReturnTrigger
{
unsigned long waitTime;
QStringList expectedOutputs;
ReturnTrigger(unsigned long time)
{
waitTime = time;
expectedOutputs = QStringList();
}
ReturnTrigger(const QStringList& outputs)
{
waitTime = 10000;
expectedOutputs = outputs;
}
ReturnTrigger(unsigned long time, const QStringList& outputs)
{
waitTime = time;
expectedOutputs = outputs;
}
};
Q_ENUM(Util::ClientType) Q_ENUM(Util::ClientType)
explicit Util(QObject *parent = nullptr); explicit Util(QObject *parent = nullptr);
void execCMD(QString cmd); void execCMD(const QString& cmd);
QString execCMDWithOutput(QString cmd, unsigned long waitTime = 2000); QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
void delay(unsigned int msec); void delay(unsigned int msec);
ClientType getClientType(); ClientType getClientType();
public slots: public slots:
void processOutput(QString output); void processOutput(const QString& output);
void setClientType(Util::ClientType clientType); void setClientType(Util::ClientType clientType);
void setRunningState(bool st);
private: private:
bool isRequiringOutput; bool isRequiringOutput;
bool isRunning;
QString* requiredOutput; QString* requiredOutput;
QTime timeStamp; QTime timeStamp;
ClientType clientType; ClientType clientType;
signals: signals:
void refreshOutput(const QString& output); void refreshOutput(const QString& output);
void write(QString data); void write(QString data); // connected to PM3Process::write(QString data);
}; };
#endif // UTIL_H #endif // UTIL_H

@ -119,7 +119,7 @@ void Mifare::chk()
"hf mf chk *" "hf mf chk *"
+ QString::number(cardType.type) + QString::number(cardType.type)
+ " ?", + " ?",
1000 + cardType.type * 1000); Util::ReturnTrigger(1000 + cardType.sector_size * 200, {"No valid", "\\|---\\|----------------\\|----------------\\|"}));
qDebug() << result; qDebug() << result;
int offset = 0; int offset = 0;
@ -183,7 +183,8 @@ void Mifare::nested()
result = util->execCMDWithOutput( result = util->execCMDWithOutput(
"hf mf nested " "hf mf nested "
+ QString::number(cardType.type) + QString::number(cardType.type)
+ " *", 10000); + " *",
Util::ReturnTrigger(10000, {"Can't found", "\\|000\\|"}));
} }
else if(util->getClientType() == Util::CLIENTTYPE_ICEMAN) else if(util->getClientType() == Util::CLIENTTYPE_ICEMAN)
{ {
@ -273,7 +274,7 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
{ {
QString data; QString data;
QString result; QString result;
bool isKeyBlock = (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(util->getClientType() == Util::CLIENTTYPE_OFFICIAL || util->getClientType() == Util::CLIENTTYPE_ICEMAN)
{ {
@ -298,7 +299,7 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
data.remove(" "); 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) // 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 // if the given key type is KeyB, it will never get the KeyA from the key block
if(isKeyBlock && keyType == KEY_A) // in this case, the Access Bits is always accessible if(isTrailerBlock && keyType == KEY_A) // in this case, the Access Bits is always accessible
{ {
data.replace(0, 12, key); data.replace(0, 12, key);
QList<quint8> ACBits = data_getACBits(data.mid(12, 8)); QList<quint8> ACBits = data_getACBits(data.mid(12, 8));
@ -307,7 +308,7 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
data.replace(20, 12, "????????????"); data.replace(20, 12, "????????????");
} }
} }
else if(isKeyBlock && keyType == KEY_B) else if(isTrailerBlock && keyType == KEY_B)
{ {
data.replace(20, 12, key);; data.replace(20, 12, key);;
data.replace(0, 12, "????????????"); // fill the keyA part with ? data.replace(0, 12, "????????????"); // fill the keyA part with ?
@ -536,8 +537,8 @@ bool Mifare::_writeblk(int blockId, KeyType keyType, const QString& key, const Q
{ {
QString result; QString result;
QString input = data.toUpper(); QString input = data.toUpper();
input.remove(" ");
input.remove(" ");
if(data_isDataValid(input) != DATA_NOSPACE) if(data_isDataValid(input) != DATA_NOSPACE)
return false; return false;
@ -601,6 +602,8 @@ void Mifare::writeSelected(TargetType targetType)
{ {
QList<int> failedBlocks; QList<int> failedBlocks;
QList<int> selectedBlocks; QList<int> selectedBlocks;
bool yes2All = false, no2All = false;
for(int i = 0; i < cardType.block_size; i++) for(int i = 0; i < cardType.block_size; i++)
{ {
if(ui->MF_dataWidget->item(i, 1)->checkState() == Qt::Checked) if(ui->MF_dataWidget->item(i, 1)->checkState() == Qt::Checked)
@ -609,6 +612,29 @@ void Mifare::writeSelected(TargetType targetType)
for(int item : selectedBlocks) for(int item : selectedBlocks)
{ {
bool result = false; bool result = false;
bool isTrailerBlock = (item < 128 && ((item + 1) % 4 == 0)) || ((item + 1) % 16 == 0);
if(isTrailerBlock && !data_isACBitsValid(dataList->at(item).mid(12, 8))) // trailer block is invalid
{
if(!yes2All && !no2All)
{
QMessageBox::StandardButton choice = QMessageBox::information(parent, tr("Info"),
tr("The Access Bits is invalid!\nIt could make the whole sector blocked irreversibly!\nContinue to write?"),
QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll);
if(choice == QMessageBox::No)
continue;
else if(choice == QMessageBox::YesToAll)
yes2All = true;
else if(choice == QMessageBox::NoToAll)
{
no2All = true;
continue;
}
}
else if(no2All)
continue;
}
if(targetType == TARGET_MIFARE) if(targetType == TARGET_MIFARE)
{ {
result = _writeblk(item, KEY_A, keyAList->at(data_b2s(item)), dataList->at(item), TARGET_MIFARE); result = _writeblk(item, KEY_A, keyAList->at(data_b2s(item)), dataList->at(item), TARGET_MIFARE);
@ -846,7 +872,7 @@ void Mifare::data_clearKey(bool clearAll)
} }
} }
bool Mifare::data_isKeyValid(const QString &key) bool Mifare::data_isKeyValid(const QString& key)
{ {
if(key.length() != 12) if(key.length() != 12)
return false; return false;
@ -912,7 +938,7 @@ void Mifare::setCardType(int type)
} }
} }
bool Mifare::data_loadDataFile(const QString &filename) bool Mifare::data_loadDataFile(const QString& filename)
{ {
QFile file(filename, this); QFile file(filename, this);
if(file.open(QIODevice::ReadOnly)) if(file.open(QIODevice::ReadOnly))
@ -959,7 +985,7 @@ bool Mifare::data_loadDataFile(const QString &filename)
} }
} }
bool Mifare::data_loadKeyFile(const QString &filename) bool Mifare::data_loadKeyFile(const QString& filename)
{ {
QFile file(filename, this); QFile file(filename, this);
if(file.open(QIODevice::ReadOnly)) if(file.open(QIODevice::ReadOnly))
@ -996,7 +1022,7 @@ bool Mifare::data_loadKeyFile(const QString &filename)
} }
} }
QString Mifare::bin2text(const QByteArray &buff, int i, int length) QString Mifare::bin2text(const QByteArray& buff, int i, int length)
{ {
QString ret = ""; QString ret = "";
char LByte, RByte; char LByte, RByte;
@ -1014,7 +1040,7 @@ QString Mifare::bin2text(const QByteArray &buff, int i, int length)
return ret; return ret;
} }
bool Mifare::data_saveDataFile(const QString &filename, bool isBin) bool Mifare::data_saveDataFile(const QString& filename, bool isBin)
{ {
QFile file(filename, this); QFile file(filename, this);
if(file.open(QIODevice::WriteOnly)) if(file.open(QIODevice::WriteOnly))
@ -1058,7 +1084,7 @@ bool Mifare::data_saveDataFile(const QString &filename, bool isBin)
} }
} }
bool Mifare::data_saveKeyFile(const QString &filename, bool isBin) bool Mifare::data_saveKeyFile(const QString& filename, bool isBin)
{ {
QFile file(filename, this); QFile file(filename, this);
if(file.open(QIODevice::WriteOnly)) if(file.open(QIODevice::WriteOnly))
@ -1153,12 +1179,12 @@ void Mifare::data_data2Key()
} }
} }
void Mifare::data_setData(int block, const QString &data) void Mifare::data_setData(int block, const QString& data)
{ {
dataList->replace(block, data); dataList->replace(block, data);
} }
void Mifare::data_setKey(int sector, KeyType keyType, const QString &key) void Mifare::data_setKey(int sector, KeyType keyType, const QString& key)
{ {
if(keyType == KEY_A) if(keyType == KEY_A)
keyAList->replace(sector, key); keyAList->replace(sector, key);
@ -1192,24 +1218,36 @@ int Mifare::data_b2s(int block)
return -1; return -1;
} }
QList<quint8> Mifare::data_getACBits(const QString& text) //return empty QList if the text is invalid bool Mifare::data_isACBitsValid(const QString& text, QList<quint8>* returnHalfBytes)
{ {
QString input = text; QString input = text;
QList<quint8> result;
input.remove(" "); input.remove(" ");
if(input.length() < 6) if(input.length() < 6)
{ {
return result; return false;
} }
input = input.left(6); input = input.left(6);
quint32 val = input.toUInt(nullptr, 16); quint32 val = input.toUInt(nullptr, 16);
quint8 halfBytes[6]; QList<quint8> halfBytes;
for(int i = 0; i < 6; i++) for(int i = 0; i < 6; i++)
{ {
halfBytes[i] = (val >> ((5 - i) * 4)) & 0xf; halfBytes.append((val >> ((5 - i) * 4)) & 0xf);
} }
qDebug() << val; qDebug() << val;
if((~halfBytes[0] & 0xf) == halfBytes[5] && (~halfBytes[1] & 0xf) == halfBytes[2] && (~halfBytes[3] & 0xf) == halfBytes[4]) if((~halfBytes[0] & 0xf) == halfBytes[5] && (~halfBytes[1] & 0xf) == halfBytes[2] && (~halfBytes[3] & 0xf) == halfBytes[4])
{
if(returnHalfBytes != nullptr)
*returnHalfBytes = halfBytes;
return true;
}
else
return false;
}
QList<quint8> Mifare::data_getACBits(const QString& text) //return empty QList if the text is invalid
{
QList<quint8> halfBytes, result;
if(data_isACBitsValid(text, &halfBytes))
{ {
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
{ {

@ -106,8 +106,9 @@ public:
void saveSniff(const QString& file); void saveSniff(const QString& file);
void data_fillKeys(); void data_fillKeys();
static QList<quint8> data_getACBits(const QString &text); static QList<quint8> data_getACBits(const QString& text);
static int data_b2s(int block); static int data_b2s(int block);
static bool data_isACBitsValid(const QString& text, QList<quint8> *returnHalfBytes = nullptr);
public slots: public slots:
signals: signals:
@ -124,9 +125,9 @@ private:
QRegularExpression* keyPattern; QRegularExpression* keyPattern;
QString bin2text(const QByteArray& buff, int start, int length); QString bin2text(const QByteArray& buff, int start, int length);
QString _readblk(int blockId, KeyType keyType, const QString &key, TargetType targetType = TARGET_MIFARE, int waitTime = 300); QString _readblk(int blockId, KeyType keyType, const QString& key, TargetType targetType = TARGET_MIFARE, int waitTime = 300);
QStringList _readsec(int sectorId, KeyType keyType, const QString &key, TargetType targetType = TARGET_MIFARE, int waitTime = 300); QStringList _readsec(int sectorId, KeyType keyType, const QString& key, TargetType targetType = TARGET_MIFARE, int waitTime = 300);
bool _writeblk(int blockId, KeyType keyType, const QString &key, const QString &data, TargetType targetType = TARGET_MIFARE, int waitTime = 300); bool _writeblk(int blockId, KeyType keyType, const QString& key, const QString& data, TargetType targetType = TARGET_MIFARE, int waitTime = 300);
}; };
#endif // MIFARE_H #endif // MIFARE_H

@ -29,6 +29,7 @@ MainWindow::MainWindow(QWidget *parent):
util = new Util(this); util = new Util(this);
mifare = new Mifare(ui, util, this); mifare = new Mifare(ui, util, this);
keyEventFilter = new MyEventFilter(QEvent::KeyRelease);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -86,7 +87,7 @@ void MainWindow::on_PM3_connectButton_clicked()
} }
} }
void MainWindow::onPM3StateChanged(bool st, QString info) void MainWindow::onPM3StateChanged(bool st, const QString& info)
{ {
pm3state = st; pm3state = st;
setState(st); setState(st);
@ -118,13 +119,10 @@ void MainWindow::refreshOutput(const QString& output)
ui->Raw_outputEdit->moveCursor(QTextCursor::End); ui->Raw_outputEdit->moveCursor(QTextCursor::End);
} }
void MainWindow::refreshCMD(const QString& cmd) void MainWindow::on_stopButton_clicked()
{ {
ui->Raw_CMDEdit->setText(cmd);
if(cmd != "" && (ui->Raw_CMDHistoryWidget->count() == 0 || ui->Raw_CMDHistoryWidget->item(ui->Raw_CMDHistoryWidget->count() - 1)->text() != cmd))
ui->Raw_CMDHistoryWidget->addItem(cmd);
}
}
// ********************************************************* // *********************************************************
// ******************** raw command ******************** // ******************** raw command ********************
@ -173,6 +171,48 @@ void MainWindow::sendMSG() // send command when pressing Enter
on_Raw_sendCMDButton_clicked(); on_Raw_sendCMDButton_clicked();
} }
void MainWindow::refreshCMD(const QString& cmd)
{
ui->Raw_CMDEdit->blockSignals(true);
ui->Raw_CMDEdit->setText(cmd);
if(cmd != "" && (ui->Raw_CMDHistoryWidget->count() == 0 || ui->Raw_CMDHistoryWidget->item(ui->Raw_CMDHistoryWidget->count() - 1)->text() != cmd))
ui->Raw_CMDHistoryWidget->addItem(cmd);
stashedCMDEditText = cmd;
stashedIndex = -1;
ui->Raw_CMDEdit->blockSignals(false);
}
void MainWindow::on_Raw_CMDEdit_keyPressed(QObject* obj_addr, QEvent& event)
{
if(obj_addr == ui->Raw_CMDEdit && event.type() == QEvent::KeyRelease)
{
QKeyEvent& keyEvent = static_cast<QKeyEvent&>(event);
if(keyEvent.key() == Qt::Key_Up)
{
if(stashedIndex > 0)
stashedIndex--;
else if(stashedIndex == -1)
stashedIndex = ui->Raw_CMDHistoryWidget->count() - 1;
}
else if(keyEvent.key() == Qt::Key_Down)
{
if(stashedIndex < ui->Raw_CMDHistoryWidget->count() - 1 && stashedIndex != -1)
stashedIndex++;
else if(stashedIndex == ui->Raw_CMDHistoryWidget->count() - 1)
stashedIndex = -1;
}
if(keyEvent.key() == Qt::Key_Up || keyEvent.key() == Qt::Key_Down)
{
ui->Raw_CMDEdit->blockSignals(true);
if(stashedIndex == -1)
ui->Raw_CMDEdit->setText(stashedCMDEditText);
else
ui->Raw_CMDEdit->setText(ui->Raw_CMDHistoryWidget->item(stashedIndex)->text());
ui->Raw_CMDEdit->blockSignals(false);
}
}
}
// ***************************************************** // *****************************************************
// ******************** mifare ******************** // ******************** mifare ********************
@ -794,16 +834,21 @@ void MainWindow::MF_widgetReset()
void MainWindow::uiInit() void MainWindow::uiInit()
{ {
connect(ui->Raw_CMDEdit, &QLineEdit::editingFinished, this, &MainWindow::sendMSG); connect(ui->Raw_CMDEdit, &QLineEdit::editingFinished, this, &MainWindow::sendMSG);
ui->Raw_CMDEdit->installEventFilter(keyEventFilter);
connect(keyEventFilter, &MyEventFilter::eventHappened, this, &MainWindow::on_Raw_CMDEdit_keyPressed);
connectStatusBar = new QLabel(this); connectStatusBar = new QLabel(this);
programStatusBar = new QLabel(this); programStatusBar = new QLabel(this);
PM3VersionBar = new QLabel(this); PM3VersionBar = new QLabel(this);
stopButton = new QPushButton(this);
setStatusBar(connectStatusBar, tr("Not Connected")); setStatusBar(connectStatusBar, tr("Not Connected"));
setStatusBar(programStatusBar, tr("Idle")); setStatusBar(programStatusBar, tr("Idle"));
setStatusBar(PM3VersionBar, ""); setStatusBar(PM3VersionBar, "");
stopButton->setText(tr("Stop"));
ui->statusbar->addPermanentWidget(PM3VersionBar, 1); ui->statusbar->addPermanentWidget(PM3VersionBar, 1);
ui->statusbar->addPermanentWidget(connectStatusBar, 1); ui->statusbar->addPermanentWidget(connectStatusBar, 1);
ui->statusbar->addPermanentWidget(programStatusBar, 1); ui->statusbar->addPermanentWidget(programStatusBar, 1);
ui->statusbar->addPermanentWidget(stopButton);
ui->MF_dataWidget->setColumnCount(3); ui->MF_dataWidget->setColumnCount(3);
ui->MF_dataWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Sec"))); ui->MF_dataWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Sec")));
@ -812,7 +857,7 @@ void MainWindow::uiInit()
ui->MF_dataWidget->verticalHeader()->setVisible(false); ui->MF_dataWidget->verticalHeader()->setVisible(false);
ui->MF_dataWidget->setColumnWidth(0, 55); ui->MF_dataWidget->setColumnWidth(0, 55);
ui->MF_dataWidget->setColumnWidth(1, 55); ui->MF_dataWidget->setColumnWidth(1, 55);
ui->MF_dataWidget->setColumnWidth(2, 430); ui->MF_dataWidget->setColumnWidth(2, 450);
ui->MF_keyWidget->setColumnCount(3); ui->MF_keyWidget->setColumnCount(3);
ui->MF_keyWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Sec"))); ui->MF_keyWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Sec")));
@ -820,8 +865,8 @@ void MainWindow::uiInit()
ui->MF_keyWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("KeyB"))); ui->MF_keyWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("KeyB")));
ui->MF_keyWidget->verticalHeader()->setVisible(false); ui->MF_keyWidget->verticalHeader()->setVisible(false);
ui->MF_keyWidget->setColumnWidth(0, 35); ui->MF_keyWidget->setColumnWidth(0, 35);
ui->MF_keyWidget->setColumnWidth(1, 115); ui->MF_keyWidget->setColumnWidth(1, 125);
ui->MF_keyWidget->setColumnWidth(2, 115); ui->MF_keyWidget->setColumnWidth(2, 125);
MF_widgetReset(); MF_widgetReset();
typeBtnGroup = new QButtonGroup(this); typeBtnGroup = new QButtonGroup(this);
@ -875,6 +920,7 @@ void MainWindow::signalInit()
connect(this, &MainWindow::connectPM3, pm3, &PM3Process::connectPM3); connect(this, &MainWindow::connectPM3, pm3, &PM3Process::connectPM3);
connect(pm3, &PM3Process::PM3StatedChanged, this, &MainWindow::onPM3StateChanged); connect(pm3, &PM3Process::PM3StatedChanged, this, &MainWindow::onPM3StateChanged);
connect(pm3, &PM3Process::PM3StatedChanged, util, &Util::setRunningState);
connect(this, &MainWindow::killPM3, pm3, &PM3Process::kill); connect(this, &MainWindow::killPM3, pm3, &PM3Process::kill);
connect(util, &Util::write, pm3, &PM3Process::write); connect(util, &Util::write, pm3, &PM3Process::write);
@ -886,9 +932,11 @@ void MainWindow::signalInit()
connect(ui->MF_UIDGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked); connect(ui->MF_UIDGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_simGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked); connect(ui->MF_simGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(ui->MF_sniffGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked); connect(ui->MF_sniffGroupBox, &QGroupBox::clicked, this, &MainWindow::on_GroupBox_clicked);
connect(stopButton, &QPushButton::clicked, this, &MainWindow::on_stopButton_clicked);
} }
void MainWindow::setStatusBar(QLabel * target, const QString & text) void MainWindow::setStatusBar(QLabel * target, const QString& text)
{ {
if(target == PM3VersionBar) if(target == PM3VersionBar)
target->setText(tr("HW Version:") + text); target->setText(tr("HW Version:") + text);
@ -898,7 +946,7 @@ void MainWindow::setStatusBar(QLabel * target, const QString & text)
target->setText(tr("State:") + text); target->setText(tr("State:") + text);
} }
void MainWindow::setTableItem(QTableWidget * widget, int row, int column, const QString & text) void MainWindow::setTableItem(QTableWidget * widget, int row, int column, const QString& text)
{ {
if(widget->item(row, column) == nullptr) if(widget->item(row, column) == nullptr)
widget->setItem(row, column, new QTableWidgetItem()); widget->setItem(row, column, new QTableWidgetItem());
@ -983,10 +1031,15 @@ void MainWindow::on_GroupBox_clicked(bool checked)
settings->endGroup(); settings->endGroup();
} }
void MainWindow::saveClientPath(const QString & path) void MainWindow::saveClientPath(const QString& path)
{ {
settings->beginGroup("Client_Path"); settings->beginGroup("Client_Path");
settings->setValue("path", path); settings->setValue("path", path);
settings->endGroup(); settings->endGroup();
} }
// *********************************************** // ***********************************************
void MainWindow::on_Raw_CMDEdit_textChanged(const QString &arg1)
{
stashedCMDEditText = arg1;
}

@ -19,7 +19,9 @@
#include <QGroupBox> #include <QGroupBox>
#include <QSizePolicy> #include <QSizePolicy>
#include <QSettings> #include <QSettings>
#include <QPushButton>
#include "common/myeventfilter.h"
#include "common/pm3process.h" #include "common/pm3process.h"
#include "module/mifare.h" #include "module/mifare.h"
#include "common/util.h" #include "common/util.h"
@ -43,11 +45,12 @@ public:
void initUI(); void initUI();
bool eventFilter(QObject *watched, QEvent *event); bool eventFilter(QObject *watched, QEvent *event);
public slots: public slots:
void refreshOutput(const QString &output); void refreshOutput(const QString& output);
void refreshCMD(const QString &cmd); void refreshCMD(const QString& cmd);
void setStatusBar(QLabel* target, const QString & text); void setStatusBar(QLabel* target, const QString& text);
void onPM3StateChanged(bool st, QString info); void onPM3StateChanged(bool st, const QString& info);
void MF_onTypeChanged(int id, bool st); void MF_onTypeChanged(int id, bool st);
void on_Raw_CMDEdit_keyPressed(QObject *obj_addr, QEvent &event);
private slots: private slots:
void on_PM3_connectButton_clicked(); void on_PM3_connectButton_clicked();
@ -148,15 +151,23 @@ private slots:
void on_MF_selectTrailerBox_stateChanged(int arg1); void on_MF_selectTrailerBox_stateChanged(int arg1);
void on_stopButton_clicked();
void on_Raw_CMDEdit_textChanged(const QString &arg1);
private: private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
QButtonGroup* typeBtnGroup; QButtonGroup* typeBtnGroup;
QLabel* connectStatusBar; QLabel* connectStatusBar;
QLabel* programStatusBar; QLabel* programStatusBar;
QLabel* PM3VersionBar; QLabel* PM3VersionBar;
QPushButton* stopButton;
QAction* myInfo; QAction* myInfo;
QAction* checkUpdate; QAction* checkUpdate;
QSettings* settings; QSettings* settings;
MyEventFilter* keyEventFilter;
QString stashedCMDEditText;
int stashedIndex = -1;
void uiInit(); void uiInit();
@ -172,12 +183,12 @@ private:
void signalInit(); void signalInit();
void MF_widgetReset(); void MF_widgetReset();
void setTableItem(QTableWidget *widget, int row, int column, const QString &text); void setTableItem(QTableWidget *widget, int row, int column, const QString& text);
void setState(bool st); void setState(bool st);
void saveClientPath(const QString &path); void saveClientPath(const QString& path);
signals: signals:
void connectPM3(const QString path, const QString port); void connectPM3(const QString& path, const QString& port);
void killPM3(); void killPM3();
void setSerialListener(const QString &name, bool state); void setSerialListener(const QString& name, bool state);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

@ -120,7 +120,7 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="mifareTab"> <widget class="QWidget" name="mifareTab">
<attribute name="title"> <attribute name="title">
@ -1168,6 +1168,219 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="lfTab">
<attribute name="title">
<string>LF/Data</string>
</attribute>
<widget class="QGroupBox" name="LF_configGroupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>121</width>
<height>211</height>
</rect>
</property>
<property name="title">
<string>LF Config</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QGroupBox" name="LF_Conf_freqGroupBox">
<property name="title">
<string>Frequency</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QRadioButton" name="LF_Conf_freq125kButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>125k</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="LF_Conf_freq134kButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>134k</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>BitRate:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Decimation:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="LF_Conf_decimationBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Averaging:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="LF_Conf_averagingBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Threshold:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="LF_Conf_thresholdBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Skips:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="LF_Conf_skipsBox"/>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="LF_Conf_bitRateBox"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QPushButton" name="LF_Conf_getButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Get</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="LF_Conf_setButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Set</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="t55xxTab">
<attribute name="title">
<string>T55xx</string>
</attribute>
<widget class="QTableWidget" name="T55_dataWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>256</width>
<height>192</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="rawTab"> <widget class="QWidget" name="rawTab">
<attribute name="title"> <attribute name="title">
<string>RawCommand</string> <string>RawCommand</string>
@ -1198,6 +1411,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum> <enum>Qt::ScrollBarAlwaysOn</enum>
</property> </property>

@ -3,7 +3,8 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
{
class MF_Attack_hardnestedDialog; class MF_Attack_hardnestedDialog;
} }
@ -19,7 +20,7 @@ public:
private: private:
Ui::MF_Attack_hardnestedDialog *ui; Ui::MF_Attack_hardnestedDialog *ui;
signals: signals:
void sendCMD(QString cmd); void sendCMD(const QString& cmd);
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
}; };

@ -26,7 +26,7 @@ private:
Ui::MF_Sim_simDialog *ui; Ui::MF_Sim_simDialog *ui;
int cardType; int cardType;
signals: signals:
void sendCMD(QString cmd); void sendCMD(const QString& cmd);
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
}; };

@ -23,7 +23,7 @@ public:
private slots: private slots:
void on_accessBitsEdit_textChanged(const QString &arg1); void on_accessBitsEdit_textChanged(const QString& arg1);
void on_blockSizeChanged(int id, bool st); void on_blockSizeChanged(int id, bool st);

@ -3,7 +3,8 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
{
class MF_UID_parameterDialog; class MF_UID_parameterDialog;
} }
@ -18,7 +19,7 @@ public:
private: private:
Ui::MF_UID_parameterDialog *ui; Ui::MF_UID_parameterDialog *ui;
signals: signals:
void sendCMD(QString cmd); void sendCMD(const QString& cmd);
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();
}; };

Loading…
Cancel
Save