Skip to content

Commit

Permalink
Merge pull request ReFirmLabs#803 from ReFirmLabs/7z_iso
Browse files Browse the repository at this point in the history
Updated ISO extractor to support more ISO sub-types
  • Loading branch information
devttys0 authored Dec 22, 2024
2 parents 7735eca + d0fdf92 commit 8c8326a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ pub mod gif;
pub mod gpg;
pub mod gzip;
pub mod inflate;
pub mod iso9660;
pub mod jboot;
pub mod jffs2;
pub mod jpeg;
Expand Down
32 changes: 32 additions & 0 deletions src/extractors/iso9660.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::extractors;
use crate::extractors::sevenzip::sevenzip_extractor;

/// Describes how to run the 7z utility to extract ISO images
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::iso9660::iso9660_extractor;
///
/// match iso9660_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn iso9660_extractor() -> extractors::common::Extractor {
// Same as the normal 7z extractor, but give the carved file an ISO file extension.
// The file extension matters, and 7z doesn't handle some ISO sub-formats correctly if the file extension is not '.iso'.
let mut extractor = sevenzip_extractor();
extractor.extension = "iso".to_string();
extractor
}
2 changes: 1 addition & 1 deletion src/magic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub fn patterns() -> Vec<signatures::common::Signature> {
magic: signatures::iso9660::iso_magic(),
parser: signatures::iso9660::iso_parser,
description: signatures::iso9660::DESCRIPTION.to_string(),
extractor: Some(extractors::tsk::tsk_extractor()),
extractor: Some(extractors::iso9660::iso9660_extractor()),
},
// linux kernel
signatures::common::Signature {
Expand Down

0 comments on commit 8c8326a

Please sign in to comment.