mirror of
https://github.com/wh201906/Proxmark3GUI.git
synced 2025-03-01 20:41:32 +08:00
Merge branch 'dev' into master
This commit is contained in:
commit
bf9b3fb076
@ -16,6 +16,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
common/myeventfilter.cpp \
|
||||
main.cpp \
|
||||
common/pm3process.cpp \
|
||||
common/util.cpp \
|
||||
@ -27,6 +28,7 @@ SOURCES += \
|
||||
ui/mf_attack_hardnesteddialog.cpp \
|
||||
|
||||
HEADERS += \
|
||||
common/myeventfilter.h \
|
||||
common/pm3process.h \
|
||||
common/util.h \
|
||||
module/mifare.h \
|
||||
|
@ -25,7 +25,7 @@ A GUI for [Proxmark3](https://github.com/Proxmark/proxmark3) client
|
||||
## Preview
|
||||

|
||||
|
||||
more previews [here](README/doc/previews.md)
|
||||
[more previews](README/doc/previews.md)
|
||||
|
||||
***
|
||||
|
||||
|
13
common/myeventfilter.cpp
Normal file
13
common/myeventfilter.cpp
Normal file
@ -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);
|
||||
}
|
22
common/myeventfilter.h
Normal file
22
common/myeventfilter.h
Normal file
@ -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);
|
||||
}
|
||||
|
||||
void PM3Process::connectPM3(const QString path, const QString port)
|
||||
void PM3Process::connectPM3(const QString& path, const QString& port)
|
||||
{
|
||||
QString result;
|
||||
Util::ClientType clientType = Util::CLIENTTYPE_OFFICIAL;
|
||||
@ -93,7 +93,6 @@ void PM3Process::testThread()
|
||||
qDebug() << "PM3:" << QThread::currentThread();
|
||||
}
|
||||
|
||||
|
||||
qint64 PM3Process::write(QString data)
|
||||
{
|
||||
return QProcess::write(data.toLatin1());
|
||||
|
@ -21,8 +21,8 @@ public:
|
||||
void testThread();
|
||||
|
||||
public slots:
|
||||
void connectPM3(const QString path, const QString port);
|
||||
void setSerialListener(const QString &name, bool state);
|
||||
void connectPM3(const QString& path, const QString& port);
|
||||
void setSerialListener(const QString& name, bool state);
|
||||
qint64 write(QString data);
|
||||
private slots:
|
||||
void onTimeout();
|
||||
@ -34,8 +34,8 @@ private:
|
||||
QTimer* serialListener;
|
||||
QSerialPortInfo* portInfo;
|
||||
signals:
|
||||
void PM3StatedChanged(bool st, QString info = "");
|
||||
void newOutput(QString output);
|
||||
void PM3StatedChanged(bool st, const QString& info = "");
|
||||
void newOutput(const QString& output);
|
||||
void changeClientType(Util::ClientType);
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@ Util::Util(QObject *parent) : QObject(parent)
|
||||
qRegisterMetaType<Util::ClientType>("Util::ClientType");
|
||||
}
|
||||
|
||||
void Util::processOutput(QString output)
|
||||
void Util::processOutput(const QString& output)
|
||||
{
|
||||
// qDebug() << "Util::processOutput:" << output;
|
||||
if(isRequiringOutput)
|
||||
@ -20,26 +20,45 @@ void Util::processOutput(QString output)
|
||||
emit refreshOutput(output);
|
||||
}
|
||||
|
||||
void Util::execCMD(QString cmd)
|
||||
void Util::execCMD(const QString& cmd)
|
||||
{
|
||||
qDebug() << cmd;
|
||||
emit write(cmd + "\r\n");
|
||||
if(isRunning)
|
||||
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 targetTime = QTime::currentTime().addMSecs(waitTime);
|
||||
QTime targetTime = QTime::currentTime().addMSecs(trigger.waitTime);
|
||||
isRequiringOutput = true;
|
||||
requiredOutput->clear();
|
||||
execCMD(cmd);
|
||||
while(QTime::currentTime() < targetTime)
|
||||
{
|
||||
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)
|
||||
{
|
||||
currTime = timeStamp;
|
||||
targetTime = timeStamp.addMSecs(waitTime);
|
||||
targetTime = timeStamp.addMSecs(trigger.waitTime);
|
||||
}
|
||||
}
|
||||
isRequiringOutput = false;
|
||||
@ -61,3 +80,8 @@ void Util::setClientType(Util::ClientType clientType)
|
||||
{
|
||||
this->clientType = clientType;
|
||||
}
|
||||
|
||||
void Util::setRunningState(bool st)
|
||||
{
|
||||
this->isRunning = st;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QMetaType>
|
||||
#include <QRegularExpression>
|
||||
|
||||
class Util : public QObject
|
||||
{
|
||||
@ -20,26 +21,49 @@ public:
|
||||
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)
|
||||
|
||||
explicit Util(QObject *parent = nullptr);
|
||||
|
||||
void execCMD(QString cmd);
|
||||
QString execCMDWithOutput(QString cmd, unsigned long waitTime = 2000);
|
||||
void execCMD(const QString& cmd);
|
||||
QString execCMDWithOutput(const QString& cmd, ReturnTrigger trigger = 10000);
|
||||
void delay(unsigned int msec);
|
||||
ClientType getClientType();
|
||||
public slots:
|
||||
void processOutput(QString output);
|
||||
void processOutput(const QString& output);
|
||||
void setClientType(Util::ClientType clientType);
|
||||
void setRunningState(bool st);
|
||||
|
||||
private:
|
||||
bool isRequiringOutput;
|
||||
bool isRunning;
|
||||
QString* requiredOutput;
|
||||
QTime timeStamp;
|
||||
ClientType clientType;
|
||||
signals:
|
||||
void refreshOutput(const QString& output);
|
||||
void write(QString data);
|
||||
void write(QString data); // connected to PM3Process::write(QString data);
|
||||
};
|
||||
|
||||
#endif // UTIL_H
|
||||
|
@ -119,7 +119,7 @@ void Mifare::chk()
|
||||
"hf mf chk *"
|
||||
+ QString::number(cardType.type)
|
||||
+ " ?",
|
||||
1000 + cardType.type * 1000);
|
||||
Util::ReturnTrigger(1000 + cardType.sector_size * 200, {"No valid", "\\|---\\|----------------\\|----------------\\|"}));
|
||||
qDebug() << result;
|
||||
|
||||
int offset = 0;
|
||||
@ -183,7 +183,8 @@ void Mifare::nested()
|
||||
result = util->execCMDWithOutput(
|
||||
"hf mf nested "
|
||||
+ QString::number(cardType.type)
|
||||
+ " *", 10000);
|
||||
+ " *",
|
||||
Util::ReturnTrigger(10000, {"Can't found", "\\|000\\|"}));
|
||||
}
|
||||
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 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)
|
||||
{
|
||||
@ -298,7 +299,7 @@ QString Mifare::_readblk(int blockId, KeyType keyType, const QString& key, Targe
|
||||
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
|
||||
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);
|
||||
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, "????????????");
|
||||
}
|
||||
}
|
||||
else if(isKeyBlock && keyType == KEY_B)
|
||||
else if(isTrailerBlock && keyType == KEY_B)
|
||||
{
|
||||
data.replace(20, 12, key);;
|
||||
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 input = data.toUpper();
|
||||
input.remove(" ");
|
||||
|
||||
input.remove(" ");
|
||||
if(data_isDataValid(input) != DATA_NOSPACE)
|
||||
return false;
|
||||
|
||||
@ -601,6 +602,8 @@ void Mifare::writeSelected(TargetType targetType)
|
||||
{
|
||||
QList<int> failedBlocks;
|
||||
QList<int> selectedBlocks;
|
||||
bool yes2All = false, no2All = false;
|
||||
|
||||
for(int i = 0; i < cardType.block_size; i++)
|
||||
{
|
||||
if(ui->MF_dataWidget->item(i, 1)->checkState() == Qt::Checked)
|
||||
@ -609,6 +612,29 @@ void Mifare::writeSelected(TargetType targetType)
|
||||
for(int item : selectedBlocks)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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);
|
||||
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);
|
||||
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 = "";
|
||||
char LByte, RByte;
|
||||
@ -1014,7 +1040,7 @@ QString Mifare::bin2text(const QByteArray &buff, int i, int length)
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Mifare::data_saveDataFile(const QString &filename, bool isBin)
|
||||
bool Mifare::data_saveDataFile(const QString& filename, bool isBin)
|
||||
{
|
||||
QFile file(filename, this);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
keyAList->replace(sector, key);
|
||||
@ -1192,24 +1218,36 @@ int Mifare::data_b2s(int block)
|
||||
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;
|
||||
QList<quint8> result;
|
||||
input.remove(" ");
|
||||
if(input.length() < 6)
|
||||
{
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
input = input.left(6);
|
||||
quint32 val = input.toUInt(nullptr, 16);
|
||||
quint8 halfBytes[6];
|
||||
QList<quint8> halfBytes;
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
halfBytes[i] = (val >> ((5 - i) * 4)) & 0xf;
|
||||
halfBytes.append((val >> ((5 - i) * 4)) & 0xf);
|
||||
}
|
||||
qDebug() << val;
|
||||
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++)
|
||||
{
|
||||
|
@ -106,8 +106,9 @@ public:
|
||||
void saveSniff(const QString& file);
|
||||
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 bool data_isACBitsValid(const QString& text, QList<quint8> *returnHalfBytes = nullptr);
|
||||
public slots:
|
||||
signals:
|
||||
|
||||
@ -124,9 +125,9 @@ private:
|
||||
QRegularExpression* keyPattern;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
bool _writeblk(int blockId, KeyType keyType, const QString& key, const QString& data, TargetType targetType = TARGET_MIFARE, int waitTime = 300);
|
||||
};
|
||||
|
||||
#endif // MIFARE_H
|
||||
|
@ -29,6 +29,7 @@ MainWindow::MainWindow(QWidget *parent):
|
||||
util = new Util(this);
|
||||
mifare = new Mifare(ui, util, this);
|
||||
|
||||
keyEventFilter = new MyEventFilter(QEvent::KeyRelease);
|
||||
}
|
||||
|
||||
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;
|
||||
setState(st);
|
||||
@ -118,13 +119,10 @@ void MainWindow::refreshOutput(const QString& output)
|
||||
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 ********************
|
||||
@ -173,6 +171,48 @@ void MainWindow::sendMSG() // send command when pressing Enter
|
||||
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 ********************
|
||||
@ -794,16 +834,21 @@ void MainWindow::MF_widgetReset()
|
||||
void MainWindow::uiInit()
|
||||
{
|
||||
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);
|
||||
programStatusBar = new QLabel(this);
|
||||
PM3VersionBar = new QLabel(this);
|
||||
stopButton = new QPushButton(this);
|
||||
setStatusBar(connectStatusBar, tr("Not Connected"));
|
||||
setStatusBar(programStatusBar, tr("Idle"));
|
||||
setStatusBar(PM3VersionBar, "");
|
||||
stopButton->setText(tr("Stop"));
|
||||
ui->statusbar->addPermanentWidget(PM3VersionBar, 1);
|
||||
ui->statusbar->addPermanentWidget(connectStatusBar, 1);
|
||||
ui->statusbar->addPermanentWidget(programStatusBar, 1);
|
||||
ui->statusbar->addPermanentWidget(stopButton);
|
||||
|
||||
ui->MF_dataWidget->setColumnCount(3);
|
||||
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->setColumnWidth(0, 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->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->verticalHeader()->setVisible(false);
|
||||
ui->MF_keyWidget->setColumnWidth(0, 35);
|
||||
ui->MF_keyWidget->setColumnWidth(1, 115);
|
||||
ui->MF_keyWidget->setColumnWidth(2, 115);
|
||||
ui->MF_keyWidget->setColumnWidth(1, 125);
|
||||
ui->MF_keyWidget->setColumnWidth(2, 125);
|
||||
|
||||
MF_widgetReset();
|
||||
typeBtnGroup = new QButtonGroup(this);
|
||||
@ -875,6 +920,7 @@ void MainWindow::signalInit()
|
||||
|
||||
connect(this, &MainWindow::connectPM3, pm3, &PM3Process::connectPM3);
|
||||
connect(pm3, &PM3Process::PM3StatedChanged, this, &MainWindow::onPM3StateChanged);
|
||||
connect(pm3, &PM3Process::PM3StatedChanged, util, &Util::setRunningState);
|
||||
connect(this, &MainWindow::killPM3, pm3, &PM3Process::kill);
|
||||
|
||||
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_simGroupBox, &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)
|
||||
target->setText(tr("HW Version:") + text);
|
||||
@ -898,7 +946,7 @@ void MainWindow::setStatusBar(QLabel * target, const QString & 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)
|
||||
widget->setItem(row, column, new QTableWidgetItem());
|
||||
@ -983,10 +1031,15 @@ void MainWindow::on_GroupBox_clicked(bool checked)
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void MainWindow::saveClientPath(const QString & path)
|
||||
void MainWindow::saveClientPath(const QString& path)
|
||||
{
|
||||
settings->beginGroup("Client_Path");
|
||||
settings->setValue("path", path);
|
||||
settings->endGroup();
|
||||
}
|
||||
// ***********************************************
|
||||
|
||||
void MainWindow::on_Raw_CMDEdit_textChanged(const QString &arg1)
|
||||
{
|
||||
stashedCMDEditText = arg1;
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
#include <QGroupBox>
|
||||
#include <QSizePolicy>
|
||||
#include <QSettings>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "common/myeventfilter.h"
|
||||
#include "common/pm3process.h"
|
||||
#include "module/mifare.h"
|
||||
#include "common/util.h"
|
||||
@ -43,11 +45,12 @@ public:
|
||||
void initUI();
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
public slots:
|
||||
void refreshOutput(const QString &output);
|
||||
void refreshCMD(const QString &cmd);
|
||||
void setStatusBar(QLabel* target, const QString & text);
|
||||
void onPM3StateChanged(bool st, QString info);
|
||||
void refreshOutput(const QString& output);
|
||||
void refreshCMD(const QString& cmd);
|
||||
void setStatusBar(QLabel* target, const QString& text);
|
||||
void onPM3StateChanged(bool st, const QString& info);
|
||||
void MF_onTypeChanged(int id, bool st);
|
||||
void on_Raw_CMDEdit_keyPressed(QObject *obj_addr, QEvent &event);
|
||||
private slots:
|
||||
|
||||
void on_PM3_connectButton_clicked();
|
||||
@ -148,15 +151,23 @@ private slots:
|
||||
|
||||
void on_MF_selectTrailerBox_stateChanged(int arg1);
|
||||
|
||||
void on_stopButton_clicked();
|
||||
void on_Raw_CMDEdit_textChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
QButtonGroup* typeBtnGroup;
|
||||
QLabel* connectStatusBar;
|
||||
QLabel* programStatusBar;
|
||||
QLabel* PM3VersionBar;
|
||||
QPushButton* stopButton;
|
||||
QAction* myInfo;
|
||||
QAction* checkUpdate;
|
||||
QSettings* settings;
|
||||
MyEventFilter* keyEventFilter;
|
||||
|
||||
QString stashedCMDEditText;
|
||||
int stashedIndex = -1;
|
||||
|
||||
void uiInit();
|
||||
|
||||
@ -172,12 +183,12 @@ private:
|
||||
|
||||
void signalInit();
|
||||
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 saveClientPath(const QString &path);
|
||||
void saveClientPath(const QString& path);
|
||||
signals:
|
||||
void connectPM3(const QString path, const QString port);
|
||||
void connectPM3(const QString& path, const QString& port);
|
||||
void killPM3();
|
||||
void setSerialListener(const QString &name, bool state);
|
||||
void setSerialListener(const QString& name, bool state);
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
218
ui/mainwindow.ui
218
ui/mainwindow.ui
@ -120,7 +120,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="mifareTab">
|
||||
<attribute name="title">
|
||||
@ -1168,6 +1168,219 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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">
|
||||
<attribute name="title">
|
||||
<string>RawCommand</string>
|
||||
@ -1198,6 +1411,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class MF_Attack_hardnestedDialog;
|
||||
}
|
||||
|
||||
@ -19,7 +20,7 @@ public:
|
||||
private:
|
||||
Ui::MF_Attack_hardnestedDialog *ui;
|
||||
signals:
|
||||
void sendCMD(QString cmd);
|
||||
void sendCMD(const QString& cmd);
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ private:
|
||||
Ui::MF_Sim_simDialog *ui;
|
||||
int cardType;
|
||||
signals:
|
||||
void sendCMD(QString cmd);
|
||||
void sendCMD(const QString& cmd);
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
private slots:
|
||||
|
||||
void on_accessBitsEdit_textChanged(const QString &arg1);
|
||||
void on_accessBitsEdit_textChanged(const QString& arg1);
|
||||
|
||||
void on_blockSizeChanged(int id, bool st);
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class MF_UID_parameterDialog;
|
||||
}
|
||||
|
||||
@ -18,7 +19,7 @@ public:
|
||||
private:
|
||||
Ui::MF_UID_parameterDialog *ui;
|
||||
signals:
|
||||
void sendCMD(QString cmd);
|
||||
void sendCMD(const QString& cmd);
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user