feat: add PE verification and complete extraction pipeline (M6)
Add PE header verification (MZ signature, PE signature, POWERPCBE machine type) to the extraction pipeline. Implement master key trial with validation for encrypted files. Update CLI extract command to show encryption/compression info. Update README with extract usage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -409,3 +409,34 @@ fn test_cli_extract_default_output_path() {
|
||||
// Clean up
|
||||
let _ = std::fs::remove_file(&expected_output);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_pe_verification_runs() {
|
||||
let data = sample_data();
|
||||
let xex = xex2tractor::parse(&data).unwrap();
|
||||
|
||||
let pe_image = extract::extract_pe_image(&data, &xex).unwrap();
|
||||
|
||||
// verify_pe_image should succeed on the extracted image
|
||||
assert!(extract::verify_pe_image(&pe_image).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cli_extract_shows_format_info() {
|
||||
let path = format!("{}/tests/data/default.xex", env!("CARGO_MANIFEST_DIR"));
|
||||
let output_path = format!("{}/target/test_extract_info.exe", env!("CARGO_MANIFEST_DIR"));
|
||||
let _ = std::fs::remove_file(&output_path);
|
||||
|
||||
let output = std::process::Command::new(env!("CARGO_BIN_EXE_xex2tractor"))
|
||||
.args(["extract", &path, &output_path])
|
||||
.output()
|
||||
.expect("failed to run xex2tractor");
|
||||
|
||||
assert!(output.status.success());
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(stdout.contains("Encryption:"));
|
||||
assert!(stdout.contains("Compression:"));
|
||||
assert!(stdout.contains("Extracted PE image"));
|
||||
|
||||
let _ = std::fs::remove_file(&output_path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user