Skip to content

Commit cbca23a

Browse files
committed
fix: updated cli with hardener from vmaware struct and fixed false positive from logic due to Hyper-X
1 parent df8b829 commit cbca23a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/cli.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,12 @@ R"(Usage:
368368
std::exit(0);
369369
}
370370

371-
static const char* color(const u8 score) {
371+
static const char* color(const u8 score, const bool is_hardened) {
372372
if (arg_bitset.test(NO_ANSI)) {
373373
return "";
374374
}
375375

376-
if (VM::is_hardened()) {
376+
if (is_hardened) {
377377
return green.c_str();
378378
}
379379

@@ -1100,10 +1100,10 @@ static void general(
11001100
{
11011101
std::cout << bold << "VM hardening: " << ansi_exit;
11021102

1103-
if (VM::is_hardened()) {
1104-
std::cout << green << "found" << ansi_exit << "\n";
1103+
if (vm.is_hardened) {
1104+
std::cout << green << "likely" << ansi_exit << "\n";
11051105
} else {
1106-
std::cout << grey << "not found" << ansi_exit << "\n";
1106+
std::cout << grey << "unlikely" << ansi_exit << "\n";
11071107
}
11081108
}
11091109

@@ -1177,7 +1177,7 @@ static void general(
11771177

11781178
// conclusion manager
11791179
{
1180-
const char* conclusion_color = color(vm.percentage);
1180+
const char* conclusion_color = color(vm.percentage, vm.is_hardened);
11811181

11821182
std::string conclusion = vm.conclusion;
11831183

src/vmaware.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12693,10 +12693,11 @@ struct VM {
1269312693
};
1269412694

1269512695
const bool hv_present = (check(VM::HYPERVISOR_BIT) || check(VM::HYPERVISOR_STR));
12696+
const bool has_hyper_x = (detected_brand(VM::HYPERVISOR_BIT) == brand_enum::HYPERV_ARTIFACT);
1269612697

1269712698
// rule 1: if VM::FIRMWARE is detected, so should VM::HYPERVISOR_BIT or VM::HYPERVISOR_STR
1269812699
const enum brand_enum firmware_brand = detected_brand(VM::FIRMWARE);
12699-
if (firmware_brand != brand_enum::NULL_BRAND && !hv_present) {
12700+
if (firmware_brand != brand_enum::NULL_BRAND && !hv_present && !has_hyper_x) {
1270012701
debug("is_hardened(): firmware and hypervisor bit/str are not detected together");
1270112702
return true;
1270212703
}
@@ -12721,7 +12722,7 @@ struct VM {
1272112722
}
1272212723

1272312724
// rule 4: if VM::TRAP or VM::NVRAM is detected, so should VM::HYPERVISOR_BIT or VM::HYPERVISOR_STR
12724-
if ((check(VM::TRAP) || check(VM::NVRAM)) && !hv_present) {
12725+
if ((check(VM::TRAP) || check(VM::NVRAM)) && !hv_present && !has_hyper_x) {
1272512726
debug("is_hardened(): trap/NVRAM and hypervisor bit/str are not detected together");
1272612727
return true;
1272712728
}

0 commit comments

Comments
 (0)