Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parsing code signature data + more load commands for mach-o #78

Merged
merged 18 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
651 changes: 651 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ yara-x-parser = { workspace = true }
yara-x-proto = { workspace = true }

lingua = { version = "1.6.0", optional = true, default-features = false, features = ["english", "german", "french", "spanish"] }
roxmltree = "0.19.0"
latonis marked this conversation as resolved.
Show resolved Hide resolved
cryptographic-message-syntax = "0.26.0"

[build-dependencies]
protobuf = { workspace = true }
Expand Down
36 changes: 36 additions & 0 deletions lib/src/modules/macho/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,42 @@ fn ep_for_arch_subtype(
None
}

/// The function for checking if any dylib name present in the main Mach-O or embedded Mach-O files
/// contain a dylib with the desired name
///
/// # Arguments
///
/// * `ctx`: A mutable reference to the scanning context.
latonis marked this conversation as resolved.
Show resolved Hide resolved
/// * `dylib_name`: The name of the dylib to check if present
///
/// # Returns
///
/// An `Option<bool>` containing if the name is found
#[module_export(name = "entitlement_present")]
fn entitlements_present(
ctx: &ScanContext,
entitlement: RuntimeString,
) -> Option<bool> {
let macho = ctx.module_output::<Macho>()?;
let expected = entitlement.as_bstr(ctx);

for entitlement in macho.entitlements.iter() {
if expected.eq_ignore_ascii_case(entitlement.as_bytes()) {
return Some(true);
}
}

for file in macho.file.iter() {
for entitlement in file.entitlements.iter() {
if expected.eq_ignore_ascii_case(entitlement.as_bytes()) {
return Some(true);
}
}
}

Some(false)
}

/// The function for checking if any dylib name present in the main Mach-O or
/// embedded Mach-O files contain a dylib with the desired name
///
Expand Down
Loading
Loading