2017-10-02 16:18:40 +00:00
|
|
|
#include "Dashboard.h"
|
|
|
|
#include "ui_Dashboard.h"
|
2018-02-04 17:27:48 +00:00
|
|
|
#include "utils/Helpers.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-10-01 19:09:42 +00:00
|
|
|
#include "MainWindow.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonDocument>
|
2017-04-13 15:14:02 +00:00
|
|
|
#include <QFile>
|
2017-04-25 23:30:36 +00:00
|
|
|
#include <QLayoutItem>
|
2017-04-13 15:14:02 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
Dashboard::Dashboard(MainWindow *main, QWidget *parent) :
|
2017-11-19 12:56:10 +00:00
|
|
|
QDockWidget(parent),
|
2017-10-01 18:08:12 +00:00
|
|
|
ui(new Ui::Dashboard),
|
|
|
|
main(main)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
connect(Core(), SIGNAL(refreshAll()), this, SLOT(updateContents()));
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
Dashboard::~Dashboard() {}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void Dashboard::updateContents()
|
|
|
|
{
|
2018-02-10 22:31:15 +00:00
|
|
|
QJsonDocument docu = Core()->getFileInfo();
|
|
|
|
QJsonObject item = docu.object()["core"].toObject();
|
|
|
|
QJsonObject item2 = docu.object()["bin"].toObject();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
this->ui->fileEdit->setText(item["file"].toString());
|
|
|
|
this->ui->formatEdit->setText(item["format"].toString());
|
|
|
|
this->ui->modeEdit->setText(item["mode"].toString());
|
|
|
|
this->ui->typeEdit->setText(item["type"].toString());
|
2018-02-04 17:27:48 +00:00
|
|
|
this->ui->sizeEdit->setText(qhelpers::formatBytecount(item["size"].toDouble()));
|
2017-04-09 19:55:06 +00:00
|
|
|
this->ui->fdEdit->setText(QString::number(item["fd"].toDouble()));
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
this->ui->archEdit->setText(item2["arch"].toString());
|
|
|
|
this->ui->langEdit->setText(item2["lang"].toString().toUpper());
|
|
|
|
this->ui->classEdit->setText(item2["class"].toString());
|
|
|
|
this->ui->machineEdit->setText(item2["machine"].toString());
|
|
|
|
this->ui->osEdit->setText(item2["os"].toString());
|
|
|
|
this->ui->subsysEdit->setText(item2["subsys"].toString());
|
|
|
|
this->ui->endianEdit->setText(item2["endian"].toString());
|
|
|
|
this->ui->compiledEdit->setText(item2["compiled"].toString());
|
2017-04-09 19:55:06 +00:00
|
|
|
this->ui->bitsEdit->setText(QString::number(item2["bits"].toDouble()));
|
2017-06-08 22:40:43 +00:00
|
|
|
|
2017-07-02 11:11:02 +00:00
|
|
|
if (!item2["relro"].isUndefined())
|
|
|
|
{
|
2017-06-09 08:40:27 +00:00
|
|
|
QString relro = item2["relro"].toString().split(" ").at(0);
|
2017-07-02 11:11:02 +00:00
|
|
|
relro[0] = relro[0].toUpper();
|
2017-06-08 22:28:42 +00:00
|
|
|
this->ui->relroEdit->setText(relro);
|
|
|
|
}
|
2017-06-02 16:35:26 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
this->ui->baddrEdit->setText(QString::number(item2["baddr"].toDouble()));
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["va"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->vaEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->vaEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["canary"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->canaryEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->canaryEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["crypto"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->cryptoEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->cryptoEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["nx"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->nxEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->nxEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["pic"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->picEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->picEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["static"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->staticEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->staticEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["stripped"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->strippedEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->strippedEdit->setText("False");
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
if (item2["relocs"].toBool() == true)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->relocsEdit->setText("True");
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->ui->relocsEdit->setText("False");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add file hashes and libraries
|
2017-10-09 18:08:35 +00:00
|
|
|
QString md5 = CutterCore::getInstance()->cmd("e file.md5");
|
|
|
|
QString sha1 = CutterCore::getInstance()->cmd("e file.sha1");
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->md5Edit->setText(md5);
|
|
|
|
ui->sha1Edit->setText(sha1);
|
|
|
|
|
2017-10-09 18:08:35 +00:00
|
|
|
QString libs = CutterCore::getInstance()->cmd("il");
|
2017-03-29 10:18:37 +00:00
|
|
|
QStringList lines = libs.split("\n", QString::SkipEmptyParts);
|
2017-04-25 23:30:36 +00:00
|
|
|
if (!lines.isEmpty())
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-04-03 08:21:45 +00:00
|
|
|
lines.removeFirst();
|
|
|
|
lines.removeLast();
|
|
|
|
}
|
2017-04-25 23:30:36 +00:00
|
|
|
|
|
|
|
// dunno: why not label->setText(lines.join("\n")?
|
|
|
|
while (ui->verticalLayout_2->count() > 0)
|
|
|
|
{
|
|
|
|
QLayoutItem *item = ui->verticalLayout_2->takeAt(0);
|
|
|
|
if (item != nullptr)
|
|
|
|
{
|
|
|
|
QWidget *w = item->widget();
|
|
|
|
if (w != nullptr)
|
|
|
|
{
|
|
|
|
w->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
delete item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-15 11:40:20 +00:00
|
|
|
for (QString lib : lines)
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
QLabel *label = new QLabel(this);
|
|
|
|
label->setText(lib);
|
|
|
|
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
ui->verticalLayout_2->addWidget(label);
|
|
|
|
}
|
2017-04-25 23:30:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
QSpacerItem *spacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding);
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->verticalLayout_2->addSpacerItem(spacer);
|
|
|
|
|
|
|
|
// Add entropy value
|
2017-10-09 18:08:35 +00:00
|
|
|
QString entropy = CutterCore::getInstance()->cmd("ph entropy").trimmed();
|
2017-03-29 10:18:37 +00:00
|
|
|
ui->lblEntropy->setText(entropy);
|
|
|
|
|
|
|
|
// Get stats for the graphs
|
2017-10-09 18:08:35 +00:00
|
|
|
QStringList stats = CutterCore::getInstance()->getStats();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|