Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use regex::Regex;
- use std::{
- fs::{self, File},
- io::{Read, Seek, SeekFrom},
- };
- fn main() {
- let maps_regex = Regex::new(r"([\w]+)-([\w]+) r").unwrap();
- let maps = fs::read_to_string("/proc/self/maps").unwrap();
- let mut mem = File::open("/proc/self/mem").unwrap();
- for map in maps.lines() {
- let captures = maps_regex.captures(&map).unwrap();
- let start_adress: usize = usize::from_str_radix(&captures[1], 16).unwrap();
- let end_adress: usize = usize::from_str_radix(&captures[2], 16).unwrap();
- mem.seek(SeekFrom::Start(start_adress as u64)).unwrap();
- let mut memory = vec![0; end_adress - start_adress];
- mem.read_exact(&mut memory).unwrap();
- let string: String = String::from_utf8_lossy(&memory)
- .chars()
- .filter(|&c| c != '�')
- .collect();
- println!("{}", string);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement