33 lines
1.1 KiB
Rust
33 lines
1.1 KiB
Rust
#[macro_use] extern crate rust_util;
|
|
|
|
use std::path::Path;
|
|
use goblin::Object;
|
|
|
|
fn main() {
|
|
let file = std::env::args().nth(1);
|
|
match file {
|
|
None => failure_and_exit!("Must assign a file"),
|
|
Some(f) => {
|
|
let path = Path::new(&f);
|
|
let buff = std::fs::read(path).unwrap_or_else(|e| failure_and_exit!("Read file: {}, failed: {}", f, e));
|
|
match Object::parse(&buff).unwrap_or_else(|e| failure_and_exit!("Read file: {}, failed: {}", f , e)) {
|
|
Object::Elf(elf) => {
|
|
success!("Found elf file: {:?}", elf.header);
|
|
}
|
|
Object::PE(pe) => {
|
|
success!("Found PE file: {:?}", pe);
|
|
}
|
|
Object::Mach(mach) => {
|
|
success!("Found mach file: {:?}", mach);
|
|
}
|
|
Object::Archive(archive) => {
|
|
success!("Fund linux archive file: {:?}", archive);
|
|
}
|
|
Object::Unknown(magic) => {
|
|
failure!("Unknown file, magic: {}", magic);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|