Updated to latest memflow, added set_mem_map support
parent
9edb44d03b
commit
2eb3ca73e6
@ -0,0 +1,57 @@
|
|||||||
|
/*!
|
||||||
|
This example shows how to use the pcileech connector in conjunction
|
||||||
|
with a specific OS layer. This example uses the `Inventory` feature of memflow
|
||||||
|
to create the connector itself and the os instance.
|
||||||
|
|
||||||
|
The example is an adaption of the memflow core process list example:
|
||||||
|
https://github.com/memflow/memflow/blob/next/memflow/examples/process_list.rs
|
||||||
|
|
||||||
|
# Remarks:
|
||||||
|
To run this example you must have the `pcileech` connector and `win32` plugin installed on your system.
|
||||||
|
Make sure they can be found in one of the following locations:
|
||||||
|
|
||||||
|
~/.local/lib/memflow/
|
||||||
|
/usr/lib/memflow/
|
||||||
|
|
||||||
|
or in any other path found in the official memflow documentation.
|
||||||
|
*/
|
||||||
|
use std::env::args;
|
||||||
|
|
||||||
|
use log::{info, Level};
|
||||||
|
|
||||||
|
use memflow::prelude::v1::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
simple_logger::SimpleLogger::new()
|
||||||
|
.with_level(Level::Debug.to_level_filter())
|
||||||
|
.init()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let connector_args = if let Some(arg) = args().nth(1) {
|
||||||
|
Args::parse(arg.as_ref()).expect("unable to parse command line arguments")
|
||||||
|
} else {
|
||||||
|
Args::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let inventory = Inventory::scan();
|
||||||
|
let connector = inventory
|
||||||
|
.create_connector("pcileech", None, &connector_args)
|
||||||
|
.expect("unable to create pcileech connector");
|
||||||
|
let mut os = inventory
|
||||||
|
.create_os("win32", Some(connector), &Args::default())
|
||||||
|
.expect("unable to create win32 instance with pcileech connector");
|
||||||
|
|
||||||
|
let process_list = os.process_info_list().expect("unable to read process list");
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"{:>5} {:>10} {:>10} {:<}",
|
||||||
|
"PID", "SYS ARCH", "PROC ARCH", "NAME"
|
||||||
|
);
|
||||||
|
|
||||||
|
for p in process_list {
|
||||||
|
info!(
|
||||||
|
"{:>5} {:^10} {:^10} {}",
|
||||||
|
p.pid, p.sys_arch, p.proc_arch, p.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*!
|
||||||
|
This example shows how to use the pcileech connector in conjunction
|
||||||
|
with a specific OS layer. This example does not use the `Inventory` feature of memflow
|
||||||
|
but hard-wires the connector instance with the OS layer directly.
|
||||||
|
|
||||||
|
The example is an adaption of the memflow core process list example:
|
||||||
|
https://github.com/memflow/memflow/blob/next/memflow/examples/process_list.rs
|
||||||
|
|
||||||
|
# Remarks:
|
||||||
|
The most flexible and recommended way to use memflow is to go through the inventory.
|
||||||
|
The inventory allows the user to swap out connectors and os layers at runtime.
|
||||||
|
For more information about the Inventory see the ps_inventory.rs example in this repository
|
||||||
|
or check out the documentation at:
|
||||||
|
https://docs.rs/memflow/0.1.5/memflow/connector/inventory/index.html
|
||||||
|
*/
|
||||||
|
use std::env::args;
|
||||||
|
|
||||||
|
use log::{info, Level};
|
||||||
|
|
||||||
|
use memflow::prelude::v1::*;
|
||||||
|
use memflow_win32::prelude::v1::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
simple_logger::SimpleLogger::new()
|
||||||
|
.with_level(Level::Debug.to_level_filter())
|
||||||
|
.init()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let connector_args = if let Some(arg) = args().nth(1) {
|
||||||
|
Args::parse(arg.as_ref()).expect("unable to parse command line arguments")
|
||||||
|
} else {
|
||||||
|
Args::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let connector = memflow_pcileech::create_connector(&connector_args, Level::Debug)
|
||||||
|
.expect("unable to create pcileech connector");
|
||||||
|
|
||||||
|
let mut os = Win32Kernel::builder(connector)
|
||||||
|
.build_default_caches()
|
||||||
|
.build()
|
||||||
|
.expect("unable to create win32 instance with pcileech connector");
|
||||||
|
|
||||||
|
let process_list = os.process_info_list().expect("unable to read process list");
|
||||||
|
|
||||||
|
info!(
|
||||||
|
"{:>5} {:>10} {:>10} {:<}",
|
||||||
|
"PID", "SYS ARCH", "PROC ARCH", "NAME"
|
||||||
|
);
|
||||||
|
|
||||||
|
for p in process_list {
|
||||||
|
info!(
|
||||||
|
"{:>5} {:^10} {:^10} {}",
|
||||||
|
p.pid, p.sys_arch, p.proc_arch, p.name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue