|
|
@ -1,6 +1,4 @@
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
@ -11,7 +9,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
|
pm3=new PM3Process;
|
|
|
|
pm3=new PM3Process;
|
|
|
|
mifare=new Mifare;
|
|
|
|
mifare=new Mifare;
|
|
|
|
connect(pm3,&PM3Process::readyRead,this,&MainWindow::refresh);
|
|
|
|
connect(pm3,&PM3Process::readyRead,this,&MainWindow::refresh);
|
|
|
|
connect(ui->commandEdit,&QLineEdit::editingFinished,this,&MainWindow::sendMSG);
|
|
|
|
connect(ui->Raw_CMDEdit,&QLineEdit::editingFinished,this,&MainWindow::sendMSG);
|
|
|
|
uiInit();
|
|
|
|
uiInit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -22,97 +20,177 @@ MainWindow::~MainWindow()
|
|
|
|
|
|
|
|
|
|
|
|
// ******************** basic functions ********************
|
|
|
|
// ******************** basic functions ********************
|
|
|
|
|
|
|
|
|
|
|
|
// *********************************************************
|
|
|
|
void MainWindow::on_PM3_refreshPortButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->PM3_portBox->clear();
|
|
|
|
|
|
|
|
ui->PM3_portBox->addItem("");
|
|
|
|
|
|
|
|
foreach(QString port,pm3->findPort())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->PM3_portBox->addItem(port);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_connectButton_clicked()
|
|
|
|
void MainWindow::on_PM3_connectButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString port=ui->portBox->currentText();
|
|
|
|
QString port=ui->PM3_portBox->currentText();
|
|
|
|
if(port=="")
|
|
|
|
if(port=="")
|
|
|
|
QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok);
|
|
|
|
QMessageBox::information(NULL, "Info", "Plz choose a port first", QMessageBox::Ok);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
qDebug()<<pm3->start(ui->PM3PathEdit->text(),port);
|
|
|
|
qDebug()<<pm3->start(ui->PM3_pathEdit->text(),port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_sendButton_clicked()
|
|
|
|
void MainWindow::on_PM3_disconnectButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(ui->CMDHistoryWidget->count()==0 || ui->CMDHistoryWidget->item(ui->CMDHistoryWidget->count()-1)->text()!=ui->commandEdit->text())
|
|
|
|
pm3->kill();
|
|
|
|
ui->CMDHistoryWidget->addItem(ui->commandEdit->text());
|
|
|
|
}
|
|
|
|
qDebug()<<(ui->commandEdit->text().toLocal8Bit());
|
|
|
|
|
|
|
|
pm3->write((ui->commandEdit->text()+"\r\n").toLocal8Bit());
|
|
|
|
// *********************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ******************** raw command ********************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_Raw_sendCMDButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(ui->Raw_CMDHistoryWidget->count()==0 || ui->Raw_CMDHistoryWidget->item(ui->Raw_CMDHistoryWidget->count()-1)->text()!=ui->Raw_CMDEdit->text())
|
|
|
|
|
|
|
|
ui->Raw_CMDHistoryWidget->addItem(ui->Raw_CMDEdit->text());
|
|
|
|
|
|
|
|
qDebug()<<(ui->Raw_CMDEdit->text().toLocal8Bit());
|
|
|
|
|
|
|
|
pm3->write((ui->Raw_CMDEdit->text()+"\r\n").toLocal8Bit());
|
|
|
|
pm3->waitForBytesWritten(3000);
|
|
|
|
pm3->waitForBytesWritten(3000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::refresh()
|
|
|
|
void MainWindow::on_Raw_clearOutputButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString btay=pm3->readLine();
|
|
|
|
ui->Raw_outputEdit->clear();
|
|
|
|
while(btay!="")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qDebug()<<btay;
|
|
|
|
|
|
|
|
ui->outputEdit->insertPlainText(btay);
|
|
|
|
|
|
|
|
btay=pm3->readLine();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->outputEdit->moveCursor(QTextCursor::End);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::sendMSG()
|
|
|
|
void MainWindow::on_Raw_moreFuncCheckBox_stateChanged(int arg1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(ui->commandEdit->hasFocus())
|
|
|
|
if(ui->Raw_moreFuncCheckBox->isChecked())
|
|
|
|
on_sendButton_clicked();
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->Raw_CMDTreeWidget->setVisible(true);
|
|
|
|
|
|
|
|
ui->Raw_CMDTreeLabel->setVisible(true);
|
|
|
|
|
|
|
|
ui->Raw_CMDHistoryWidget->setVisible(true);
|
|
|
|
|
|
|
|
ui->Raw_CMDHistoryLabel->setVisible(true);
|
|
|
|
|
|
|
|
ui->Raw_clearHistoryButton->setVisible(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->Raw_CMDTreeWidget->setVisible(false);
|
|
|
|
|
|
|
|
ui->Raw_CMDTreeLabel->setVisible(false);
|
|
|
|
|
|
|
|
ui->Raw_CMDHistoryWidget->setVisible(false);
|
|
|
|
|
|
|
|
ui->Raw_CMDHistoryLabel->setVisible(false);
|
|
|
|
|
|
|
|
ui->Raw_clearHistoryButton->setVisible(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_disconnectButton_clicked()
|
|
|
|
void MainWindow::on_Raw_clearHistoryButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pm3->kill();
|
|
|
|
ui->Raw_CMDHistoryWidget->clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_clearButton_clicked()
|
|
|
|
void MainWindow::on_Raw_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->outputEdit->clear();
|
|
|
|
ui->Raw_CMDEdit->setText(item->text());
|
|
|
|
|
|
|
|
ui->Raw_CMDEdit->setFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_portButton_clicked()
|
|
|
|
// *****************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ******************** mifare ********************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_MF_Attack_chkButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->portBox->clear();
|
|
|
|
pm3->setRequiringOutput(true);
|
|
|
|
ui->portBox->addItem("");
|
|
|
|
ui->Raw_CMDEdit->setText("hf mf chk *1 ?");
|
|
|
|
foreach(QString port,pm3->findPort())
|
|
|
|
on_Raw_sendCMDButton_clicked();
|
|
|
|
|
|
|
|
while(pm3->waitForReadyRead(5000))
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
QString result=pm3->getRequiredOutput();
|
|
|
|
|
|
|
|
pm3->setRequiringOutput(false);
|
|
|
|
|
|
|
|
result=result.mid(result.indexOf("|---|----------------|----------------|"));
|
|
|
|
|
|
|
|
QStringList keys=result.split("\r\n");
|
|
|
|
|
|
|
|
for(int i=0;i<16;i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->portBox->addItem(port);
|
|
|
|
ui->MF_keyWidget->setItem(i,1,new QTableWidgetItem(keys[i+3].mid(7,12).trimmed().toUpper()));
|
|
|
|
|
|
|
|
ui->MF_keyWidget->setItem(i,2,new QTableWidgetItem(keys[i+3].mid(24,12).trimmed().toUpper()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug()<<"***********\n"<<keys<<"***********\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_moreFuncCheckBox_stateChanged(int arg1)
|
|
|
|
void MainWindow::on_MF_Attack_nestedButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(ui->moreFuncCheckBox->isChecked())
|
|
|
|
pm3->setRequiringOutput(true);
|
|
|
|
{
|
|
|
|
ui->Raw_CMDEdit->setText("hf mf nested 1 *");
|
|
|
|
ui->CMDTreeWidget->setVisible(true);
|
|
|
|
on_Raw_sendCMDButton_clicked();
|
|
|
|
ui->CMDTreeLabel->setVisible(true);
|
|
|
|
while(pm3->waitForReadyRead(5000))
|
|
|
|
ui->CMDHistoryWidget->setVisible(true);
|
|
|
|
;
|
|
|
|
ui->CMDHistoryLabel->setVisible(true);
|
|
|
|
QString result=pm3->getRequiredOutput();
|
|
|
|
ui->clearHistoryButton->setVisible(true);
|
|
|
|
pm3->setRequiringOutput(false);
|
|
|
|
}
|
|
|
|
result=result.mid(result.indexOf("|---|----------------|---|----------------|---|"));
|
|
|
|
else
|
|
|
|
QStringList keys=result.split("\r\n");
|
|
|
|
|
|
|
|
for(int i=0;i<16;i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->CMDTreeWidget->setVisible(false);
|
|
|
|
if(keys[i+3].at(23)=='1')
|
|
|
|
ui->CMDTreeLabel->setVisible(false);
|
|
|
|
ui->MF_keyWidget->setItem(i,1,new QTableWidgetItem(keys[i+3].mid(7,12).trimmed().toUpper()));
|
|
|
|
ui->CMDHistoryWidget->setVisible(false);
|
|
|
|
if(keys[i+3].at(44)=='1')
|
|
|
|
ui->CMDHistoryLabel->setVisible(false);
|
|
|
|
ui->MF_keyWidget->setItem(i,2,new QTableWidgetItem(keys[i+3].mid(28,12).trimmed().toUpper()));
|
|
|
|
ui->clearHistoryButton->setVisible(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug()<<"***********\n"<<keys<<"***********\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_MF_Attack_hardnestedButton_clicked()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_clearHistoryButton_clicked()
|
|
|
|
void MainWindow::on_MF_Attack_sniffButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->CMDHistoryWidget->clear();
|
|
|
|
ui->Raw_CMDEdit->setText("hf mf sniff");
|
|
|
|
|
|
|
|
on_Raw_sendCMDButton_clicked();
|
|
|
|
|
|
|
|
ui->funcTab->setCurrentIndex(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_CMDHistoryWidget_itemDoubleClicked(QListWidgetItem *item)
|
|
|
|
void MainWindow::on_MF_Attack_listButton_clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui->commandEdit->setText(item->text());
|
|
|
|
ui->Raw_CMDEdit->setText("hf list mf");
|
|
|
|
ui->commandEdit->setFocus();
|
|
|
|
on_Raw_sendCMDButton_clicked();
|
|
|
|
|
|
|
|
ui->funcTab->setCurrentIndex(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ******************** other ********************
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::refresh()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString btay=pm3->readLine();
|
|
|
|
|
|
|
|
while(btay!="")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qDebug()<<btay;
|
|
|
|
|
|
|
|
ui->Raw_outputEdit->insertPlainText(btay);
|
|
|
|
|
|
|
|
btay=pm3->readLine();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->Raw_outputEdit->moveCursor(QTextCursor::End);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::sendMSG()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(ui->Raw_CMDEdit->hasFocus())
|
|
|
|
|
|
|
|
on_Raw_sendCMDButton_clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::uiInit()
|
|
|
|
void MainWindow::uiInit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
connectStatusBar=new QLabel(this);
|
|
|
|
|
|
|
|
programStatusBar=new QLabel(this);
|
|
|
|
|
|
|
|
PM3VersionBar=new QLabel(this);
|
|
|
|
|
|
|
|
setStatusBar(connectStatusBar,"Not Connected");
|
|
|
|
|
|
|
|
setStatusBar(programStatusBar,"Idle");
|
|
|
|
|
|
|
|
setStatusBar(PM3VersionBar,"");
|
|
|
|
|
|
|
|
ui->statusbar->addPermanentWidget(PM3VersionBar,1);
|
|
|
|
|
|
|
|
ui->statusbar->addPermanentWidget(connectStatusBar,1);
|
|
|
|
|
|
|
|
ui->statusbar->addPermanentWidget(programStatusBar,1);
|
|
|
|
|
|
|
|
|
|
|
|
ui->MF_dataWidget->setColumnCount(3);
|
|
|
|
ui->MF_dataWidget->setColumnCount(3);
|
|
|
|
ui->MF_dataWidget->setRowCount(64);
|
|
|
|
ui->MF_dataWidget->setRowCount(64);
|
|
|
|
ui->MF_dataWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Sector"));
|
|
|
|
ui->MF_dataWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Sector"));
|
|
|
@ -139,46 +217,25 @@ void MainWindow::uiInit()
|
|
|
|
ui->MF_keyWidget->setColumnWidth(1,200);
|
|
|
|
ui->MF_keyWidget->setColumnWidth(1,200);
|
|
|
|
ui->MF_keyWidget->setColumnWidth(2,200);
|
|
|
|
ui->MF_keyWidget->setColumnWidth(2,200);
|
|
|
|
|
|
|
|
|
|
|
|
on_moreFuncCheckBox_stateChanged(0);
|
|
|
|
on_Raw_moreFuncCheckBox_stateChanged(0);
|
|
|
|
on_portButton_clicked();
|
|
|
|
on_PM3_refreshPortButton_clicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_MFChkButton_clicked()
|
|
|
|
void MainWindow::setStatusBar(QLabel* target,const QString & text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pm3->setRequiringOutput(true);
|
|
|
|
if(target==PM3VersionBar)
|
|
|
|
ui->commandEdit->setText("hf mf chk *1 ?");
|
|
|
|
target->setText("Version:"+text);
|
|
|
|
on_sendButton_clicked();
|
|
|
|
else if(target==connectStatusBar)
|
|
|
|
while(pm3->waitForReadyRead(5000))
|
|
|
|
target->setText("Connecton State:"+text);
|
|
|
|
;
|
|
|
|
else if(target==programStatusBar)
|
|
|
|
QString result=pm3->getRequiredOutput();
|
|
|
|
target->setText("Program State:"+text);
|
|
|
|
pm3->setRequiringOutput(false);
|
|
|
|
|
|
|
|
result=result.mid(result.indexOf("|---|----------------|----------------|"));
|
|
|
|
|
|
|
|
QStringList keys=result.split("\r\n");
|
|
|
|
|
|
|
|
for(int i=0;i<16;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui->MF_keyWidget->setItem(i,1,new QTableWidgetItem(keys[i+3].mid(7,12).trimmed().toUpper()));
|
|
|
|
|
|
|
|
ui->MF_keyWidget->setItem(i,2,new QTableWidgetItem(keys[i+3].mid(24,12).trimmed().toUpper()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug()<<"***********\n"<<keys<<"***********\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_MFNestedButton_clicked()
|
|
|
|
// ***********************************************
|
|
|
|
{
|
|
|
|
|
|
|
|
pm3->setRequiringOutput(true);
|
|
|
|
|
|
|
|
ui->commandEdit->setText("hf mf nested 1 *");
|
|
|
|
|
|
|
|
on_sendButton_clicked();
|
|
|
|
|
|
|
|
while(pm3->waitForReadyRead(5000))
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
QString result=pm3->getRequiredOutput();
|
|
|
|
|
|
|
|
pm3->setRequiringOutput(false);
|
|
|
|
|
|
|
|
result=result.mid(result.indexOf("|---|----------------|---|----------------|---|"));
|
|
|
|
|
|
|
|
QStringList keys=result.split("\r\n");
|
|
|
|
|
|
|
|
for(int i=0;i<16;i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(keys[i+3].at(23)=='1')
|
|
|
|
|
|
|
|
ui->MF_keyWidget->setItem(i,1,new QTableWidgetItem(keys[i+3].mid(7,12).trimmed().toUpper()));
|
|
|
|
|
|
|
|
if(keys[i+3].at(44)=='1')
|
|
|
|
|
|
|
|
ui->MF_keyWidget->setItem(i,2,new QTableWidgetItem(keys[i+3].mid(28,12).trimmed().toUpper()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug()<<"***********\n"<<keys<<"***********\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|