mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 19:26:42 +01:00
parse with goblin
This commit is contained in:
parent
52f5c58519
commit
3d29608171
1 changed files with 23 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use clap::Parser;
|
||||
use std::path::Path;
|
||||
use goblin::{error, Object};
|
||||
use exe::pe::{PE, VecPE};
|
||||
use exe::types::{ImportDirectory, ImportData, CCharString};
|
||||
|
||||
|
|
@ -25,18 +26,29 @@ impl VestalCli {
|
|||
}
|
||||
}
|
||||
fn inspect (&self, path: impl AsRef<Path>) -> Usually<()> {
|
||||
let image = VecPE::from_disk_file(path)?;
|
||||
let import_directory = ImportDirectory::parse(&image)?;
|
||||
for descriptor in import_directory.descriptors {
|
||||
let name = descriptor.get_name(&image)?.as_str()?;
|
||||
println!("\n{name}:");
|
||||
for import in descriptor.get_imports(&image).unwrap() {
|
||||
match import {
|
||||
ImportData::Ordinal(x) => println!("{name} #{}", x),
|
||||
ImportData::ImportByName(s) => println!("{name} {}", s)
|
||||
}
|
||||
}
|
||||
let buffer = std::fs::read(path.as_ref())?;
|
||||
match Object::parse(&buffer)? {
|
||||
Object::PE(pe) => {
|
||||
println!("PE: {}", path.as_ref().display());
|
||||
//println!("Exports: {:#?}", &pe.export_data);
|
||||
println!("Exports: {:#?}", &pe.exports.len());
|
||||
//println!("Imports: {:#?}", &pe.import_data);
|
||||
println!("Imports: {:#?}", &pe.imports.len());
|
||||
},
|
||||
_ => panic!("not a PE")
|
||||
}
|
||||
//let image = VecPE::from_disk_file(path)?;
|
||||
//let import_directory = ImportDirectory::parse(&image)?;
|
||||
//for descriptor in import_directory.descriptors {
|
||||
//let name = descriptor.get_name(&image)?.as_str()?;
|
||||
//println!("\n{name}:");
|
||||
//for import in descriptor.get_imports(&image).unwrap() {
|
||||
//match import {
|
||||
//ImportData::Ordinal(x) => println!("{name} #{x}"),
|
||||
//ImportData::ImportByName(s) => println!("{name} {s}")
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue