mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-07 14:56:41 +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 clap::Parser;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use goblin::{error, Object};
|
||||||
use exe::pe::{PE, VecPE};
|
use exe::pe::{PE, VecPE};
|
||||||
use exe::types::{ImportDirectory, ImportData, CCharString};
|
use exe::types::{ImportDirectory, ImportData, CCharString};
|
||||||
|
|
||||||
|
|
@ -25,18 +26,29 @@ impl VestalCli {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn inspect (&self, path: impl AsRef<Path>) -> Usually<()> {
|
fn inspect (&self, path: impl AsRef<Path>) -> Usually<()> {
|
||||||
let image = VecPE::from_disk_file(path)?;
|
let buffer = std::fs::read(path.as_ref())?;
|
||||||
let import_directory = ImportDirectory::parse(&image)?;
|
match Object::parse(&buffer)? {
|
||||||
for descriptor in import_directory.descriptors {
|
Object::PE(pe) => {
|
||||||
let name = descriptor.get_name(&image)?.as_str()?;
|
println!("PE: {}", path.as_ref().display());
|
||||||
println!("\n{name}:");
|
//println!("Exports: {:#?}", &pe.export_data);
|
||||||
for import in descriptor.get_imports(&image).unwrap() {
|
println!("Exports: {:#?}", &pe.exports.len());
|
||||||
match import {
|
//println!("Imports: {:#?}", &pe.import_data);
|
||||||
ImportData::Ordinal(x) => println!("{name} #{}", x),
|
println!("Imports: {:#?}", &pe.imports.len());
|
||||||
ImportData::ImportByName(s) => println!("{name} {}", s)
|
},
|
||||||
}
|
_ => 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue