Skip to content

Commit

Permalink
Merge pull request #777 from ReFirmLabs/encrpted_img
Browse files Browse the repository at this point in the history
Added encrpted_img signature
  • Loading branch information
devttys0 authored Nov 28, 2024
2 parents 2645c23 + 3032340 commit 5f923f8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/magic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,17 @@ pub fn patterns() -> Vec<signatures::common::Signature> {
description: signatures::logfs::DESCRIPTION.to_string(),
extractor: None,
},
// encrpted_img
signatures::common::Signature {
name: "encrpted_img".to_string(),
short: true,
magic_offset: 0,
always_display: false,
magic: signatures::encrpted_img::encrpted_img_magic(),
parser: signatures::encrpted_img::encrpted_img_parser,
description: signatures::encrpted_img::DESCRIPTION.to_string(),
extractor: None,
},
];

binary_signatures
Expand Down
1 change: 1 addition & 0 deletions src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub mod dxbc;
pub mod ecos;
pub mod efigpt;
pub mod elf;
pub mod encrpted_img;
pub mod ext;
pub mod fat;
pub mod gif;
Expand Down
32 changes: 32 additions & 0 deletions src/signatures/encrpted_img.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::signatures::common::{
SignatureError, SignatureResult, CONFIDENCE_LOW, CONFIDENCE_MEDIUM,
};

/// Human readable description
pub const DESCRIPTION: &str = "D-Link Encrpted Image";

/// encrpted_img firmware images always start with these bytes
pub fn encrpted_img_magic() -> Vec<Vec<u8>> {
vec![b"encrpted_img".to_vec()]
}

/// Validates the encrpted_img header
pub fn encrpted_img_parser(
_file_data: &[u8],
offset: usize,
) -> Result<SignatureResult, SignatureError> {
// Successful return value
let mut result = SignatureResult {
offset,
description: DESCRIPTION.to_string(),
confidence: CONFIDENCE_MEDIUM,
..Default::default()
};

// Nothing to really validate here
if offset != 0 {
result.confidence = CONFIDENCE_LOW;
}

Ok(result)
}

0 comments on commit 5f923f8

Please sign in to comment.