Skip to content

Commit d0fdf92

Browse files
committed
Updated ISO extractor to support more ISO sub-types
1 parent 7735eca commit d0fdf92

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/extractors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ pub mod gif;
158158
pub mod gpg;
159159
pub mod gzip;
160160
pub mod inflate;
161+
pub mod iso9660;
161162
pub mod jboot;
162163
pub mod jffs2;
163164
pub mod jpeg;

src/extractors/iso9660.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use crate::extractors;
2+
use crate::extractors::sevenzip::sevenzip_extractor;
3+
4+
/// Describes how to run the 7z utility to extract ISO images
5+
///
6+
/// ```
7+
/// use std::io::ErrorKind;
8+
/// use std::process::Command;
9+
/// use binwalk::extractors::common::ExtractorType;
10+
/// use binwalk::extractors::iso9660::iso9660_extractor;
11+
///
12+
/// match iso9660_extractor().utility {
13+
/// ExtractorType::None => panic!("Invalid extractor type of None"),
14+
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
15+
/// ExtractorType::External(cmd) => {
16+
/// if let Err(e) = Command::new(&cmd).output() {
17+
/// if e.kind() == ErrorKind::NotFound {
18+
/// panic!("External extractor '{}' not found", cmd);
19+
/// } else {
20+
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
21+
/// }
22+
/// }
23+
/// }
24+
/// }
25+
/// ```
26+
pub fn iso9660_extractor() -> extractors::common::Extractor {
27+
// Same as the normal 7z extractor, but give the carved file an ISO file extension.
28+
// The file extension matters, and 7z doesn't handle some ISO sub-formats correctly if the file extension is not '.iso'.
29+
let mut extractor = sevenzip_extractor();
30+
extractor.extension = "iso".to_string();
31+
extractor
32+
}

src/magic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub fn patterns() -> Vec<signatures::common::Signature> {
168168
magic: signatures::iso9660::iso_magic(),
169169
parser: signatures::iso9660::iso_parser,
170170
description: signatures::iso9660::DESCRIPTION.to_string(),
171-
extractor: Some(extractors::tsk::tsk_extractor()),
171+
extractor: Some(extractors::iso9660::iso9660_extractor()),
172172
},
173173
// linux kernel
174174
signatures::common::Signature {

0 commit comments

Comments
 (0)