Add sha256 and crc32 to the hexdump widget (#2006)

* Add SHA256 and CRC32 to hexdump widget
* Fix layout
* Add copied-to-clipboard messages
This commit is contained in:
Itay Cohen 2020-01-13 21:48:43 +02:00 committed by GitHub
parent b3776a6b73
commit 3eeb631c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 247 additions and 131 deletions

View File

@ -29,6 +29,8 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
ui->copyMD5->setIcon(QIcon(":/img/icons/copy.svg")); ui->copyMD5->setIcon(QIcon(":/img/icons/copy.svg"));
ui->copySHA1->setIcon(QIcon(":/img/icons/copy.svg")); ui->copySHA1->setIcon(QIcon(":/img/icons/copy.svg"));
ui->copySHA256->setIcon(QIcon(":/img/icons/copy.svg"));
ui->copyCRC32->setIcon(QIcon(":/img/icons/copy.svg"));
ui->splitter->setChildrenCollapsible(false); ui->splitter->setChildrenCollapsible(false);
@ -51,10 +53,14 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) :
showSidePanel(true); showSidePanel(true);
}); });
ui->bytesMD5->setPlaceholderText("Select bytes to display information"); // Set placeholders for the line-edit components
ui->bytesEntropy->setPlaceholderText("Select bytes to display information"); QString placeholder = tr("Select bytes to display information");
ui->bytesSHA1->setPlaceholderText("Select bytes to display information"); ui->bytesMD5->setPlaceholderText(placeholder);
ui->hexDisasTextEdit->setPlaceholderText("Select bytes to display information"); ui->bytesEntropy->setPlaceholderText(placeholder);
ui->bytesSHA1->setPlaceholderText(placeholder);
ui->bytesSHA256->setPlaceholderText(placeholder);
ui->bytesCRC32->setPlaceholderText(placeholder);
ui->hexDisasTextEdit->setPlaceholderText(placeholder);
setupFonts(); setupFonts();
@ -190,6 +196,8 @@ void HexdumpWidget::clearParseWindow()
ui->bytesEntropy->setText(""); ui->bytesEntropy->setText("");
ui->bytesMD5->setText(""); ui->bytesMD5->setText("");
ui->bytesSHA1->setText(""); ui->bytesSHA1->setText("");
ui->bytesSHA256->setText("");
ui->bytesCRC32->setText("");
} }
void HexdumpWidget::showSidePanel(bool show) void HexdumpWidget::showSidePanel(bool show)
@ -271,9 +279,13 @@ void HexdumpWidget::updateParseWindow(RVA start_address, int size)
// Fill the information tab hashes and entropy // Fill the information tab hashes and entropy
ui->bytesMD5->setText(Core()->cmd("ph md5 " + argument).trimmed()); ui->bytesMD5->setText(Core()->cmd("ph md5 " + argument).trimmed());
ui->bytesSHA1->setText(Core()->cmd("ph sha1 " + argument).trimmed()); ui->bytesSHA1->setText(Core()->cmd("ph sha1 " + argument).trimmed());
ui->bytesSHA256->setText(Core()->cmd("ph sha256 " + argument).trimmed());
ui->bytesCRC32->setText(Core()->cmd("ph crc32 " + argument).trimmed());
ui->bytesEntropy->setText(Core()->cmd("ph entropy " + argument).trimmed()); ui->bytesEntropy->setText(Core()->cmd("ph entropy " + argument).trimmed());
ui->bytesMD5->setCursorPosition(0); ui->bytesMD5->setCursorPosition(0);
ui->bytesSHA1->setCursorPosition(0); ui->bytesSHA1->setCursorPosition(0);
ui->bytesSHA256->setCursorPosition(0);
ui->bytesCRC32->setCursorPosition(0);
} }
} }
@ -333,8 +345,7 @@ void HexdumpWidget::on_copyMD5_clicked()
QString md5 = ui->bytesMD5->text(); QString md5 = ui->bytesMD5->text();
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(md5); clipboard->setText(md5);
// FIXME Core()->message("MD5 copied to clipboard: " + md5);
// this->main->addOutput("MD5 copied to clipboard: " + md5);
} }
void HexdumpWidget::on_copySHA1_clicked() void HexdumpWidget::on_copySHA1_clicked()
@ -342,10 +353,24 @@ void HexdumpWidget::on_copySHA1_clicked()
QString sha1 = ui->bytesSHA1->text(); QString sha1 = ui->bytesSHA1->text();
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(sha1); clipboard->setText(sha1);
// FIXME Core()->message("SHA1 copied to clipboard: " + sha1);
// this->main->addOutput("SHA1 copied to clipboard: " + sha1);
} }
void HexdumpWidget::on_copySHA256_clicked()
{
QString sha256 = ui->bytesSHA256->text();
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(sha256);
Core()->message("SHA256 copied to clipboard: " + sha256);
}
void HexdumpWidget::on_copyCRC32_clicked()
{
QString crc32 = ui->bytesCRC32->text();
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(crc32);
Core()->message("CRC32 copied to clipboard: " + crc32);
}
void HexdumpWidget::selectHexPreview() void HexdumpWidget::selectHexPreview()
{ {

View File

@ -79,6 +79,8 @@ private slots:
void on_hexSideTab_2_currentChanged(int index); void on_hexSideTab_2_currentChanged(int index);
void on_copyMD5_clicked(); void on_copyMD5_clicked();
void on_copySHA1_clicked(); void on_copySHA1_clicked();
void on_copySHA256_clicked();
void on_copyCRC32_clicked();
}; };
#endif // HEXDUMPWIDGET_H #endif // HEXDUMPWIDGET_H

View File

@ -57,7 +57,7 @@
<enum>QTabWidget::North</enum> <enum>QTabWidget::North</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<property name="usesScrollButtons"> <property name="usesScrollButtons">
<bool>true</bool> <bool>true</bool>
@ -334,52 +334,185 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabHistogram_2"> <widget class="QWidget" name="tabHistogram_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title"> <attribute name="title">
<string notr="true">Information</string> <string notr="true">Information</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_25"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing"> <item>
<number>6</number> <layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0">
</property> <property name="sizeConstraint">
<property name="leftMargin"> <enum>QLayout::SetDefaultConstraint</enum>
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>5</number> <number>8</number>
</property> </property>
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>6</number> <number>10</number>
</property> </property>
<property name="leftMargin"> <item row="3" column="0">
<number>5</number> <widget class="QLabel" name="labelSHA256">
</property>
<property name="rightMargin">
<number>5</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="midLineWidth">
<number>4</number>
</property>
<property name="text">
<string>SHA256:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="bytesMD5">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSHA1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SHA1:</string>
</property>
</widget>
</item>
<item row="3" column="2" alignment="Qt::AlignRight">
<widget class="QToolButton" name="copySHA256">
<property name="toolTip">
<string>Copy SHA256</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="copySHA1">
<property name="toolTip">
<string notr="true">Copy SHA1</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="bytesCRC32">
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2" alignment="Qt::AlignRight">
<widget class="QToolButton" name="copyCRC32">
<property name="toolTip">
<string>Copy CRC32</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QLineEdit" name="bytesEntropy">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEntropy">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Entropy:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="bytesSHA1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelMD5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -389,96 +522,39 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_8"> <widget class="QLabel" name="labelCRC32">
<property name="spacing">
<number>5</number>
</property>
<item>
<widget class="QLineEdit" name="bytesMD5">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="frame"> <property name="text">
<bool>false</bool> <string>CRC32:</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="2">
<widget class="QToolButton" name="copyMD5"> <widget class="QToolButton" name="copyMD5">
<property name="toolTip"> <property name="toolTip">
<string notr="true">Copy MD5</string> <string notr="true">Copy MD5</string>
</property> </property>
<property name="text"> <property name="layoutDirection">
<string notr="true"/> <enum>Qt::RightToLeft</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>SHA1:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="spacing">
<number>5</number>
</property>
<item>
<widget class="QLineEdit" name="bytesSHA1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="copySHA1">
<property name="toolTip">
<string notr="true">Copy SHA1</string>
</property> </property>
<property name="text"> <property name="text">
<string notr="true"/> <string notr="true"/>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Entropy:</string>
</property>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="bytesEntropy"> <widget class="QLineEdit" name="bytesSHA256">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frame"> <property name="frame">
<bool>false</bool> <bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property> </property>
<property name="readOnly"> <property name="readOnly">
<bool>true</bool> <bool>true</bool>
@ -487,6 +563,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>