2017-03-29 10:18:37 +00:00
|
|
|
#include "dashboard.h"
|
|
|
|
#include "ui_dashboard.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonDocument>
|
2017-04-13 15:14:02 +00:00
|
|
|
#include <QFile>
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
Dashboard::Dashboard(MainWindow *main, QWidget *parent) :
|
2017-04-13 15:14:02 +00:00
|
|
|
DockWidget(parent),
|
2017-03-29 10:18:37 +00:00
|
|
|
ui(new Ui::Dashboard)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
// Radare core found in:
|
|
|
|
this->main = main;
|
|
|
|
|
|
|
|
//this->updateContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
Dashboard::~Dashboard()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
void Dashboard::setup()
|
|
|
|
{
|
|
|
|
updateContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Dashboard::refresh()
|
|
|
|
{
|
|
|
|
updateContents();
|
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void Dashboard::updateContents()
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Parse and add JSON file info
|
|
|
|
QString info = this->main->core->getFileInfo();
|
|
|
|
|
|
|
|
QJsonDocument docu = QJsonDocument::fromJson(info.toUtf8());
|
|
|
|
QJsonObject object = docu.object();
|
|
|
|
QJsonValue value_core = object.value(QString("core"));
|
|
|
|
QJsonObject item = value_core.toObject();
|
|
|
|
//qDebug() << tr("QJsonObject of description: ") << item;
|
|
|
|
|
|
|
|
QJsonValue value_bin = object.value(QString("bin"));
|
|
|
|
//qDebug() << value;
|
|
|
|
QJsonObject item2 = value_bin.toObject();
|
|
|
|
//qDebug() << tr("QJsonObject of description: ") << item;
|
|
|
|
|
|
|
|
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());
|
2017-04-09 19:55:06 +00:00
|
|
|
this->ui->sizeEdit->setText(QString::number(item["size"].toDouble()));
|
|
|
|
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-03-29 10:18:37 +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");
|
|
|
|
this->ui->canaryEdit->setStyleSheet("color: rgb(255, 0, 0);");
|
|
|
|
}
|
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");
|
|
|
|
this->ui->nxEdit->setStyleSheet("color: rgb(255, 0, 0);");
|
|
|
|
}
|
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");
|
|
|
|
this->ui->picEdit->setStyleSheet("color: rgb(255, 0, 0);");
|
|
|
|
}
|
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
|
|
|
|
QString md5 = this->main->core->cmd("e file.md5");
|
|
|
|
QString sha1 = this->main->core->cmd("e file.sha1");
|
|
|
|
ui->md5Edit->setText(md5);
|
|
|
|
ui->sha1Edit->setText(sha1);
|
|
|
|
|
|
|
|
QString libs = this->main->core->cmd("il");
|
|
|
|
QStringList lines = libs.split("\n", QString::SkipEmptyParts);
|
2017-04-09 19:55:06 +00:00
|
|
|
if (! lines.isEmpty())
|
|
|
|
{
|
2017-04-03 08:21:45 +00:00
|
|
|
lines.removeFirst();
|
|
|
|
lines.removeLast();
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
foreach (QString lib, lines)
|
|
|
|
{
|
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-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
|
|
|
|
QString entropy = this->main->core->cmd("ph entropy").trimmed();
|
|
|
|
ui->lblEntropy->setText(entropy);
|
|
|
|
|
|
|
|
// Get stats for the graphs
|
|
|
|
QStringList stats = this->main->core->getStats();
|
|
|
|
|
|
|
|
// Add data to HTML graphs (stats)
|
|
|
|
QFile html(":/html/stats.html");
|
2017-04-09 19:55:06 +00:00
|
|
|
if (!html.open(QIODevice::ReadOnly))
|
|
|
|
{
|
2017-04-09 20:36:17 +00:00
|
|
|
QMessageBox::information(this, "error", html.errorString());
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
QString code = html.readAll();
|
|
|
|
html.close();
|
|
|
|
|
|
|
|
QString data = QString("%1, %2, %3, %4, %5, %6").arg(stats.at(0)).arg(stats.at(1)).arg(stats.at(2)).arg(stats.at(3)).arg(stats.at(4)).arg(stats.at(5));
|
|
|
|
code.replace("MEOW", data);
|
|
|
|
ui->statsWebView->setHtml(code);
|
|
|
|
|
|
|
|
// Add data to polar graph
|
|
|
|
QFile html2(":/html/radar.html");
|
2017-04-09 19:55:06 +00:00
|
|
|
if (!html2.open(QIODevice::ReadOnly))
|
|
|
|
{
|
2017-04-09 20:36:17 +00:00
|
|
|
QMessageBox::information(this, "error", html2.errorString());
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
QString code2 = html2.readAll();
|
|
|
|
html2.close();
|
|
|
|
|
|
|
|
code2.replace("MEOW", data);
|
|
|
|
code2.replace("WOEM", data);
|
|
|
|
ui->polarWebView->setHtml(code2);
|
|
|
|
}
|
2017-04-13 15:14:02 +00:00
|
|
|
|