This commit is contained in:
wh201906 2020-04-07 18:16:00 +08:00
parent af7db3ac85
commit 164656a7bc
7 changed files with 207 additions and 86 deletions

View file

@ -1,4 +1,4 @@
QT += core gui
QT += core gui serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
@ -31,3 +31,8 @@ FORMS += \
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
VERSION = 0.0.1
QMAKE_TARGET_PRODUCT = "Proxmark3GUI"
QMAKE_TARGET_DESCRIPTION = "Proxmark3GUI"
QMAKE_TARGET_COMPANY = "wh201906"

View file

@ -1,2 +1,9 @@
# Proxmark3GUI
Developing...
A GUI for Proxmark3 client
***
Update Log:
## V0.0.1
+ a dumb version with a useless GUI and a serial choose box.

View file

@ -7,7 +7,13 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
pm3=new PM3Process;
connect(pm3,PM3Process::readyReadStandardError,this,MainWindow::on_pushButton_3_clicked);
connect(pm3,&PM3Process::readyRead,this,&MainWindow::refresh);
connect(ui->commandEdit,&QLineEdit::editingFinished,this,&MainWindow::sendMSG);
ui->portBox->addItem("");
foreach(QString port,pm3->findPort())
{
ui->portBox->addItem(port);
}
}
MainWindow::~MainWindow()
@ -16,21 +22,46 @@ MainWindow::~MainWindow()
}
void MainWindow::on_pushButton_clicked()
void MainWindow::on_connectButton_clicked()
{
qDebug()<<pm3->init("E:/Documents/source/qt/pm3/win64/proxmark3.exe","COM4");
QString port=ui->portBox->currentText();
if(port=="")
QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok);
else
qDebug()<<pm3->start(ui->PM3PathEdit->text(),port);
}
void MainWindow::on_pushButton_2_clicked()
void MainWindow::on_sendButton_clicked()
{
qDebug()<<ui->plainTextEdit_2->toPlainText().toLocal8Bit();
pm3->write(ui->plainTextEdit_2->toPlainText().toLocal8Bit());
qDebug()<<(ui->commandEdit->text().toLocal8Bit());
pm3->write((ui->commandEdit->text()+"\r\n").toLocal8Bit());
pm3->waitForBytesWritten(3000);
}
void MainWindow::on_pushButton_3_clicked()
void MainWindow::refresh()
{
QByteArray btay=pm3->readAllStandardOutput();
qDebug()<<btay;
ui->plainTextEdit->appendPlainText(btay);
QByteArray btay=pm3->readLine();
while(btay!="")
{
qDebug()<<btay;
ui->outputEdit->insertPlainText(btay);
btay=pm3->readLine();
}
ui->outputEdit->moveCursor(QTextCursor::End);
}
void MainWindow::sendMSG()
{
if(ui->commandEdit->hasFocus())
on_sendButton_clicked();
}
void MainWindow::on_disconnectButton_clicked()
{
pm3->kill();
}
void MainWindow::on_clearButton_clicked()
{
ui->outputEdit->clear();
}

View file

@ -4,6 +4,7 @@
#include <QMainWindow>
#include <QProcess>
#include <QDebug>
#include <QMessageBox>
#include "pm3process.h"
QT_BEGIN_NAMESPACE
@ -18,13 +19,18 @@ public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
public slots:
void refresh();
private slots:
void on_pushButton_clicked();
void on_connectButton_clicked();
void on_pushButton_2_clicked();
void on_sendButton_clicked();
void on_pushButton_3_clicked();
void on_disconnectButton_clicked();
void on_clearButton_clicked();
void sendMSG();
private:
Ui::MainWindow *ui;
PM3Process* pm3;

View file

@ -6,80 +6,135 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<width>450</width>
<height>310</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>Proxmark3GUI</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>440</x>
<y>120</y>
<width>83</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="geometry">
<rect>
<x>110</x>
<y>120</y>
<width>281</width>
<height>181</height>
</rect>
</property>
</widget>
<widget class="QPlainTextEdit" name="plainTextEdit_2">
<property name="geometry">
<rect>
<x>100</x>
<y>340</y>
<width>291</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>450</x>
<y>350</y>
<width>83</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Send</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>560</x>
<y>350</y>
<width>83</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Read</string>
</property>
</widget>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="PM3PathEdit">
<property name="text">
<string>proxmark3</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="portBox"/>
</item>
<item>
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disconnectButton">
<property name="text">
<string>Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="funcTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="rawTab">
<attribute name="title">
<string>RawCommand</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPlainTextEdit" name="outputEdit">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<widget class="QLineEdit" name="commandEdit"/>
</item>
<item>
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="text">
<string>ClearOutput</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<width>450</width>
<height>22</height>
</rect>
</property>

View file

@ -2,14 +2,28 @@
PM3Process::PM3Process(QObject* parent): QProcess(parent)
{
setProcessChannelMode(PM3Process::MergedChannels);
}
bool PM3Process::init(const QString path, const QString port)
QStringList PM3Process::findPort()
{
bool success=true;
this->start(path, QStringList(port));
qDebug()<<waitForStarted();
qDebug()<<waitForReadyRead(3000);
return true;
QSerialPort serial;
QStringList retList;
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
{
serial.setPort(info);
if(serial.open(QIODevice::ReadWrite))
{
retList<<info.portName();
serial.close();
}
}
return retList;
}
bool PM3Process::start(const QString path, const QString port)
{
// using "-f" option to make the client output flushed after every print.
QProcess::start(path, QStringList()<<port<<"-f",QProcess::Unbuffered|QProcess::ReadWrite);
return waitForStarted();
}

View file

@ -4,13 +4,16 @@
#include <QProcess>
#include <QString>
#include <QDebug>
#include <QtSerialPort/QSerialPortInfo>
#include <QtSerialPort/QSerialPort>
class PM3Process : public QProcess
{
Q_OBJECT
public:
explicit PM3Process(QObject* parent=nullptr);
bool init(const QString path, const QString port);
bool start(const QString path, const QString port);
QStringList findPort();
};
#endif // PM3PROCESS_H