Skip to content

Commit

Permalink
[Dropper] + implement Dropper UI objects tab page frontend (done) #182
Browse files Browse the repository at this point in the history
…#181

Signed-off-by: Gheorghita Mutu <gheorghitamutu@gmail.com>
  • Loading branch information
gheorghitamutu committed May 1, 2024
1 parent b916c81 commit 586e542
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 32 deletions.
57 changes: 29 additions & 28 deletions GenericPlugins/Dropper/include/Cryptographic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,41 @@ enum class Types {

static const std::string_view DEFAULT_CRC_DESCRIPTION{ "A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and "
"storage devices to detect accidental changes to digital data." };
static const std::string_view MISSING_DESCRIPTION{ "Missing description." };

static const std::map<Types, Metadata> TYPES_MAP{
{ Types::CRC16Table, { "CRC 16 Table", DEFAULT_CRC_DESCRIPTION, false } },
{ Types::CRC16Table8bit1, { "CRC 16 Table (8 bit - 1)", DEFAULT_CRC_DESCRIPTION, false } },
{ Types::CRC16Table8bit2, { "CRC 16 Table (8 bit - 2)", DEFAULT_CRC_DESCRIPTION, false } },
{ Types::CRC32Table, { "CRC 32 Table", DEFAULT_CRC_DESCRIPTION, false } },
{ Types::CRC64Table, { "CRC 64 Table", DEFAULT_CRC_DESCRIPTION, false } },
{ Types::MD5InitValues, { "MD5 Init Values", "", false } },
{ Types::SHA1InitValues, { "SHA1 Init Values", "", false } },
{ Types::ZinflateLengthStarts, { "Zinflate LengthStarts", "", false } },
{ Types::ZinflateLengthExtraBits, { "Zinflate LengthExtraBits", "", false } },
{ Types::ZinflateDistanceStarts, { "Zinflate DistanceStarts", "", false } },
{ Types::ZinflateDistanceExtraBits, { "Zinflate DistanceExtraBits", "", false } },
{ Types::ZdeflateLengthCodes, { "Zdeflate LengthCodes", "", false } },
{ Types::BlowfishPInit, { "Blowfish P-Init", "", false } },
{ Types::BlowfishSInit, { "Blowfish S-Init", "", false } },
{ Types::RijndaelTe0, { "Rijndael Te0", "", false } },
{ Types::RijndaelTe1, { "Rijndael Te1", "", false } },
{ Types::RijndaelTe2, { "Rijndael Te2", "", false } },
{ Types::RijndaelTe3, { "Rijndael Te3", "", false } },
{ Types::RijndaelTe4, { "Rijndael Te4", "", false } },
{ Types::RijndaelTd0, { "Rijndael Td0", "", false } },
{ Types::RijndaelTd1, { "Rijndael Td1", "", false } },
{ Types::RijndaelTd2, { "Rijndael Td2", "", false } },
{ Types::RijndaelTd3, { "Rijndael Td3", "", false } },
{ Types::RijndaelTd4, { "Rijndael Td4", "", false } },
{ Types::RC2PITABLE, { "RC2 PITABLE", "", false } },
{ Types::PKCSDigestDecorationMD2, { "PKCS DigestDecoration MD2", "", false } },
{ Types::PKCSDigestDecorationMD5, { "PKCS DigestDecoration MD5", "", false } },
{ Types::PKCSDigestDecorationRIPEMD160, { "PKCS DigestDecoration RIPEMD160", "", false } },
{ Types::PKCSDigestDecorationTiger, { "PKCS DigestDecoration Tiger", "", false } },
{ Types::PKCSDigestDecorationSHA256, { "PKCS DigestDecoration SHA256", "", false } },
{ Types::PKCSDigestDecorationSHA384, { "PKCS DigestDecoration SHA384", "", false } },
{ Types::PKCSDigestDecorationSHA512, { "PKCS DigestDecoration SHA512", "", false } },
{ Types::RC6Stub, { "RC6 Stub", "", false } },
{ Types::MD5InitValues, { "MD5 Init Values", MISSING_DESCRIPTION, false } },
{ Types::SHA1InitValues, { "SHA1 Init Values", MISSING_DESCRIPTION, false } },
{ Types::ZinflateLengthStarts, { "Zinflate LengthStarts", MISSING_DESCRIPTION, false } },
{ Types::ZinflateLengthExtraBits, { "Zinflate LengthExtraBits", MISSING_DESCRIPTION, false } },
{ Types::ZinflateDistanceStarts, { "Zinflate DistanceStarts", MISSING_DESCRIPTION, false } },
{ Types::ZinflateDistanceExtraBits, { "Zinflate DistanceExtraBits", MISSING_DESCRIPTION, false } },
{ Types::ZdeflateLengthCodes, { "Zdeflate LengthCodes", MISSING_DESCRIPTION, false } },
{ Types::BlowfishPInit, { "Blowfish P-Init", MISSING_DESCRIPTION, false } },
{ Types::BlowfishSInit, { "Blowfish S-Init", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTe0, { "Rijndael Te0", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTe1, { "Rijndael Te1", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTe2, { "Rijndael Te2", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTe3, { "Rijndael Te3", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTe4, { "Rijndael Te4", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTd0, { "Rijndael Td0", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTd1, { "Rijndael Td1", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTd2, { "Rijndael Td2", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTd3, { "Rijndael Td3", MISSING_DESCRIPTION, false } },
{ Types::RijndaelTd4, { "Rijndael Td4", MISSING_DESCRIPTION, false } },
{ Types::RC2PITABLE, { "RC2 PITABLE", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationMD2, { "PKCS DigestDecoration MD2", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationMD5, { "PKCS DigestDecoration MD5", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationRIPEMD160, { "PKCS DigestDecoration RIPEMD160", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationTiger, { "PKCS DigestDecoration Tiger", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationSHA256, { "PKCS DigestDecoration SHA256", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationSHA384, { "PKCS DigestDecoration SHA384", MISSING_DESCRIPTION, false } },
{ Types::PKCSDigestDecorationSHA512, { "PKCS DigestDecoration SHA512", MISSING_DESCRIPTION, false } },
{ Types::RC6Stub, { "RC6 Stub", MISSING_DESCRIPTION, false } },
};
} // namespace GView::GenericPlugins::Droppper::Cryptographic
5 changes: 5 additions & 0 deletions GenericPlugins/Dropper/include/DropperUI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class DropperUI : public Window
Reference<ListView> objectsPlugins;
std::vector<ItemMetadata> objectsMetadata;
Reference<Label> currentObjectDescription;
Reference<TextField> objectsFilename;
Reference<CheckBox> checkRecursiveInObjects;
Reference<CheckBox> writeObjectsLog;
Reference<CheckBox> openLogInView;
Reference<CheckBox> openDroppedObjects;

private:
bool DropBinary();
Expand Down
89 changes: 85 additions & 4 deletions GenericPlugins/Dropper/src/DropperUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ constexpr int32 TAB_ID_OBJECTS = 2;
constexpr int32 TAB_ID_STRINGS = 3;
constexpr int32 TAB_ID_FORMAT_INFORMATION = 4;

constexpr int32 BUTTON_ID_CANCEL = 1;
constexpr int32 BUTTON_ID_RUN = 2;
constexpr int32 BUTTON_ID_CANCEL = 1;
constexpr int32 BUTTON_ID_RUN = 2;
constexpr int32 BUTTON_ID_SELECT_ALL_OBJECTS = 3;
constexpr int32 BUTTON_ID_DESELECT_ALL_OBJECTS = 4;

constexpr int32 RADIO_GROUP_COMPUTATION = 1;
constexpr int32 RADIO_ID_FILE = 1;
constexpr int32 RADIO_ID_SELECTION = 2;

constexpr int32 CHECKBOX_ID_OPEN_DROPPED_FILE = 1;
constexpr int32 CHECKBOX_ID_OPEN_DROPPED_FILE = 1;
constexpr int32 CHECKBOX_ID_RECURSIVE_OBJECTS = 2;
constexpr int32 CHECKBOX_ID_WRITE_LOG_OBJECTS = 3;
constexpr int32 CHECKBOX_ID_OPEN_LOG_OBJECTS = 4;
constexpr int32 CHECKBOX_ID_OPEN_DROPPED_OBJECTS = 5;

constexpr int32 RADIO_GROUP_BINARY_DATA_FILE = 2;
constexpr int32 RADIO_ID_OVERWRITE_FILE = 1;
Expand Down Expand Up @@ -92,6 +98,19 @@ DropperUI::DropperUI(Reference<GView::Object> object) : Window("Dropper", "d:c,w
this->objectsPlugins->GetColumn(0).SetWidth(100.0);

this->currentObjectDescription = Factory::Label::Create(tpo, "Object description", "x:42%,y:4,w:56%,h:4");
Factory::Label::Create(tpo, "Objects name prefix", "x:42%,y:6,w:20%");
this->objectsFilename = Factory::TextField::Create(tpo, lusb, "x:64%,y:6,w:30%");

this->checkRecursiveInObjects = Factory::CheckBox::Create(tpo, "Check recursive&ly in objects", "x:42%,y:8,w:56%", CHECKBOX_ID_RECURSIVE_OBJECTS);
this->writeObjectsLog = Factory::CheckBox::Create(tpo, "Write objec&ts log", "x:42%,y:9,w:56%", CHECKBOX_ID_WRITE_LOG_OBJECTS);
this->openLogInView = Factory::CheckBox::Create(tpo, "Open log as list &view", "x:42%,y:10,w:56%", CHECKBOX_ID_WRITE_LOG_OBJECTS);
this->openDroppedObjects = Factory::CheckBox::Create(tpo, "Open &dropped objects", "x:42%,y:11,w:56%", CHECKBOX_ID_OPEN_DROPPED_OBJECTS);

this->checkRecursiveInObjects->SetChecked(true);
this->writeObjectsLog->SetChecked(true);

Factory::Button::Create(tpo, "&Select all objects", "x:42%,y:17,w:25%", BUTTON_ID_SELECT_ALL_OBJECTS);
Factory::Button::Create(tpo, "&Deselect all objects", "x:69%,y:17,w:25%", BUTTON_ID_DESELECT_ALL_OBJECTS);

const auto AddSubItem = [this](ListViewItem parent, ObjectCategory category, uint32 subcategory, const Metadata& md) {
LocalUnicodeStringBuilder<1024> lusb;
Expand Down Expand Up @@ -120,7 +139,7 @@ DropperUI::DropperUI(Reference<GView::Object> object) : Window("Dropper", "d:c,w
switch (k) {
case ObjectCategory::Archives:
for (const auto& [kk, vv] : Archives::TYPES_MAP) {
auto _ = AddSubItem(item, k, static_cast<uint32>(kk), vv);
metadata.children.emplace_back(AddSubItem(item, k, static_cast<uint32>(kk), vv));
}
break;
case ObjectCategory::Cryptographic:
Expand Down Expand Up @@ -266,6 +285,20 @@ bool DropperUI::OnEvent(Reference<Control> control, Event eventType, int32 ID)

return true;
}
if (ID == BUTTON_ID_SELECT_ALL_OBJECTS) {
const auto count = this->objectsPlugins->GetItemsCount();
for (uint32 i = 0; i < count; i++) {
this->objectsPlugins->GetItem(i).SetCheck(true);
}
return true;
}
if (ID == BUTTON_ID_DESELECT_ALL_OBJECTS) {
const auto count = this->objectsPlugins->GetItemsCount();
for (uint32 i = 0; i < count; i++) {
this->objectsPlugins->GetItem(i).SetCheck(false);
}
return true;
}
break;

case AppCUI::Controls::Event::CheckedStatusChanged:
Expand Down Expand Up @@ -305,8 +338,56 @@ bool DropperUI::OnEvent(Reference<Control> control, Event eventType, int32 ID)
auto data = item.GetData<ItemMetadata>();

if (eventType == Event::ListViewItemChecked) {
if (data->parent.has_value()) {
data->parent->SetCheck(false);
for (auto& c : data->parent->GetData<ItemMetadata>()->children) {
if (c.IsChecked()) {
data->parent->SetCheck(true);
break;
}
}
} else {
for (auto& c : data->children) {
c.SetCheck(item.IsChecked());
}
}

return true;
}

if (eventType == Event::ListViewCurrentItemChanged) {
if (data->parent.has_value()) {
switch (data->category) {
case ObjectCategory::Archives:
this->currentObjectDescription->SetText(Archives::TYPES_MAP.at(static_cast<Archives::Types>(data->subcategory)).description);
break;
case ObjectCategory::Cryptographic:
this->currentObjectDescription->SetText(Cryptographic::TYPES_MAP.at(static_cast<Cryptographic::Types>(data->subcategory)).description);
break;
case ObjectCategory::Executables:
this->currentObjectDescription->SetText(Executables::TYPES_MAP.at(static_cast<Executables::Types>(data->subcategory)).description);
break;
case ObjectCategory::HtmlObjects:
this->currentObjectDescription->SetText(HtmlObjects::TYPES_MAP.at(static_cast<HtmlObjects::Types>(data->subcategory)).description);
break;
case ObjectCategory::Image:
this->currentObjectDescription->SetText(Images::TYPES_MAP.at(static_cast<Images::Types>(data->subcategory)).description);
break;
case ObjectCategory::Multimedia:
this->currentObjectDescription->SetText(Multimedia::TYPES_MAP.at(static_cast<Multimedia::Types>(data->subcategory)).description);
break;
case ObjectCategory::SpecialStrings:
this->currentObjectDescription->SetText(SpecialStrings::TYPES_MAP.at(static_cast<SpecialStrings::Types>(data->subcategory)).description);
break;
default:
this->currentObjectDescription->SetText("NO DESCRIPTION");
break;
}
} else {
const auto& description = OBJECT_DECRIPTION_MAP.at(this->objectsPlugins->GetCurrentItem().GetData<ItemMetadata>()->category);
this->currentObjectDescription->SetText(description);
}
return true;
}
} break;

Expand Down

0 comments on commit 586e542

Please sign in to comment.