diff --git a/radare2 b/radare2 index 08478fdd..2bd7459f 160000 --- a/radare2 +++ b/radare2 @@ -1 +1 @@ -Subproject commit 08478fdd29d8ce2a6c61fbd7b207bffc10682938 +Subproject commit 2bd7459f71bdae0d2e04efd9b15cc8a666a2c101 diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 26adeece..1f27f6be 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -535,7 +535,7 @@ bool CutterCore::loadFile(QString path, ut64 baddr, ut64 mapaddr, int perms, int } ut64 hashLimit = getConfigut64("cfg.hashlimit"); - r_bin_file_hash(core->bin, hashLimit, path.toUtf8().constData(), NULL); + r_bin_file_compute_hashes(core->bin, hashLimit); fflush(stdout); return true; diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp index ed369020..f345f2cb 100644 --- a/src/widgets/Dashboard.cpp +++ b/src/widgets/Dashboard.cpp @@ -75,9 +75,42 @@ void Dashboard::updateContents() setBool(this->ui->relocsEdit, item2, "relocs"); // Add file hashes, analysis info and libraries + QJsonObject hashes = Core()->cmdj("itj").object(); - setPlainText(ui->md5Edit, hashes["md5"].toString()); - setPlainText(ui->sha1Edit, hashes["sha1"].toString()); + + // Add hashes as a pair of Hash Name : Hash Value. + for (const QString& key : hashes.keys()) { + // Create a bold QString with the hash name uppercased + QString label = QString("%1:").arg(key.toUpper()); + + // Define a Read-Only line edit to display the hash value + QLineEdit *hashLineEdit = new QLineEdit(); + hashLineEdit->setReadOnly(true); + hashLineEdit->setText(hashes.value(key).toString()); + // Set cursor position to begining to avoid long hashes (e.g sha256) + // to look truncated at the begining + hashLineEdit->setCursorPosition(0); + + // Add both controls to a form layout in a single row + ui->formLayout_2->addRow(new QLabel(label), hashLineEdit); + } + + // Add the Entropy value of the file to the dashboard + { + // Scope for TempConfig + TempConfig tempConfig; + tempConfig.set("io.va", false); + + // Calculate the Entropy of the entire binary from offset 0 to $s + // where $s is the size of the entire file + QString entropy = Core()->cmd("ph entropy $s @ 0").trimmed(); + + // Define a Read-Only line edit to display the entropy value + QLineEdit *entropyLineEdit = new QLineEdit(); + entropyLineEdit->setReadOnly(true); + entropyLineEdit->setText(entropy); + ui->formLayout_2->addRow(new QLabel(tr("Entropy:")), entropyLineEdit); + } QJsonObject analinfo = Core()->cmdj("aaij").object(); setPlainText(ui->functionsLineEdit, QString::number(analinfo["fcns"].toInt())); @@ -123,15 +156,6 @@ void Dashboard::updateContents() QSpacerItem *spacer = new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding); ui->verticalLayout_2->addSpacerItem(spacer); - // Add entropy value - { - // Scope for TempConfig - TempConfig tempConfig; - tempConfig.set("io.va", false); - QString entropy = Core()->cmd("ph entropy $s @ 0").trimmed(); - ui->lblEntropy->setText(entropy); - } - // Get stats for the graphs QStringList stats = Core()->getStats(); diff --git a/src/widgets/Dashboard.ui b/src/widgets/Dashboard.ui index 0c020356..b599e782 100644 --- a/src/widgets/Dashboard.ui +++ b/src/widgets/Dashboard.ui @@ -56,7 +56,7 @@ 0 0 1055 - 982 + 980 @@ -1017,7 +1017,7 @@ - + 0 @@ -1058,12 +1058,15 @@ - + 0 + + 5 + @@ -1075,99 +1078,6 @@ 3 - - - - - 75 - true - - - - MD5: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - false - - - true - - - - - - - - 75 - true - - - - SHA1: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - false - - - true - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Entropy: - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - - - -