-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 31 additions & 36 deletions
67
Payload_Type/thanatos/agent/thanatos/src/os/windows/platform.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,47 @@ | ||
use ffiwrappers::windows::sysinfoapi::{OsVersionInfo, ProductType}; | ||
use ffiwrappers::windows::sysinfoapi::OsVersionInfo; | ||
|
||
use crate::proto::checkin::windows_info::Product; | ||
use base_profile::msg::checkin::windows_info::Product; | ||
|
||
macro_rules! product_mapping { | ||
macro_rules! map_product { | ||
($v:ident, $($field:ident),*) => { | ||
match $v { | ||
ffiwrappers::windows::sysinfoapi::ProductType::Other(o) => $crate::proto::checkin::windows_info::Product::Other(o), | ||
$(ffiwrappers::windows::sysinfoapi::ProductType::$field => $crate::proto::checkin::windows_info::Product::ProductType($crate::proto::checkin::WindowsProductType::$field.into()),)* | ||
ffiwrappers::windows::sysinfoapi::ProductType::Other(o) => base_profile::msg::checkin::windows_info::Product::Other(o), | ||
$(ffiwrappers::windows::sysinfoapi::ProductType::$field => base_profile::msg::checkin::windows_info::Product::ProductType(base_profile::msg::checkin::WindowsProductType::$field.into()),)* | ||
} | ||
}; | ||
} | ||
|
||
impl From<ProductType> for Product { | ||
fn from(value: ProductType) -> Self { | ||
product_mapping!( | ||
value, | ||
Core, | ||
Professional, | ||
Education, | ||
Enterprise, | ||
ProWorkstation, | ||
ProForEducation, | ||
EnterpriseEvaluation, | ||
DatacenterServer, | ||
DatacenterEvaluationServer, | ||
DatacenterServerCore, | ||
DatacenterServerCoreV, | ||
DatacenterServerV, | ||
EnterpriseServer, | ||
EnterpriseServerCore, | ||
EnterpriseServerCoreV, | ||
EnterpriseServerV, | ||
HomeBasic, | ||
StandardServer, | ||
StandardEvaluationServer, | ||
StandardServerCore, | ||
StandardServerCoreV, | ||
StandardServerV | ||
) | ||
} | ||
} | ||
|
||
pub fn build_number() -> u32 { | ||
let osversion = OsVersionInfo::new(); | ||
osversion.build_number() | ||
} | ||
|
||
pub fn product() -> Product { | ||
let osversion = OsVersionInfo::new(); | ||
osversion.product_type().into() | ||
let product_type = osversion.product_type(); | ||
map_product!( | ||
product_type, | ||
Core, | ||
Professional, | ||
Education, | ||
Enterprise, | ||
ProWorkstation, | ||
ProForEducation, | ||
EnterpriseEvaluation, | ||
DatacenterServer, | ||
DatacenterEvaluationServer, | ||
DatacenterServerCore, | ||
DatacenterServerCoreV, | ||
DatacenterServerV, | ||
EnterpriseServer, | ||
EnterpriseServerCore, | ||
EnterpriseServerCoreV, | ||
EnterpriseServerV, | ||
HomeBasic, | ||
StandardServer, | ||
StandardEvaluationServer, | ||
StandardServerCore, | ||
StandardServerCoreV, | ||
StandardServerV | ||
) | ||
} |