MCPcopy Create free account
hub / github.com/MagnetForensics/dumpit-linux / main

Function main

src/main.rs:802–884  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

800}
801
802fn main() -> Result<()> {
803 env_logger::Builder::new().filter_level(LevelFilter::max()).init();
804
805 println!("DumpIt (For Linux - x64 & ARM64) {}", CRATE_VERSION);
806 println!("Linux memory acquisition that makes sense.");
807 println!("Copyright (c) 2022, Magnet Forensics, Inc.");
808 println!("");
809
810 let args = Args::parse();
811 let out_path = args.output_path;
812 let is_archive = !args.raw;
813
814 let out_path = match out_path {
815 Some(o) => o,
816 None => {
817 // Generate the destination file name if no file is provided.
818 let now = Utc::now();
819 let uts = uname()?;
820
821 // The main memory dump.
822 let mut file_name = format!("dumpit.{}.{}-{:02}-{:02}-{:02}{:02}",
823 uts.release().to_str().unwrap_or("uname"),
824 now.year(), now.month(), now.day(), now.hour(), now.minute());
825
826 if is_archive {
827 file_name += ".tar.zst"
828 } else {
829 file_name += ".core";
830 }
831
832 pause();
833 file_name
834 }
835 };
836
837 if args.pipe {
838 debug!("Destination pipe: {}", out_path);
839 } else {
840 debug!("Destination file: {}", out_path);
841 }
842
843 let mut image = DumpItForLinux::new()?;
844 image.init()?;
845 // image.display();
846
847 let start = Instant::now();
848
849 if args.pipe {
850 if !Path::new(&out_path).exists() {
851 info!("Pipe does not exist, creating...");
852 if let Err(e) = unix_named_pipe::create(&out_path, Some(0600)) {
853 error!("Failed to create pipe: {}", e);
854 }
855 info!("Pipe created at {}", out_path);
856 }
857
858 info!("Waiting for reader at {}", out_path);
859 let mut pipe = OpenOptions::new()

Callers

nothing calls this directly

Calls 4

pauseFunction · 0.85
initMethod · 0.80
write_to_archiveMethod · 0.80
write_kcore_dumpitMethod · 0.80

Tested by

no test coverage detected