Skip to content

Commit a80787d

Browse files
authored
Merge pull request #73 from thewh1teagle/feat/fix-impersonate
fix: impersonate with winlogon or lsass
2 parents 058594d + c493502 commit a80787d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

rookie-rs/src/browser/chromium.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use crate::common::{date, enums::*, sqlite};
2-
use crate::config::Browser;
32
use eyre::{bail, Result};
43
use std::path::PathBuf;
54

5+
#[allow(unused)]
6+
use crate::config::Browser;
7+
68
#[cfg(target_os = "windows")]
79
use crate::windows;
810

rookie-rs/src/windows/appbound/impersonate.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,22 @@ fn get_process_name(pid: u32) -> Result<String> {
8282
}
8383
}
8484

85-
fn get_lsass_pid() -> Result<u32> {
85+
fn get_system_process_pid() -> Result<u32> {
86+
let mut fallback_pid = None;
87+
8688
for pid in get_process_pids()? {
87-
if get_process_name(pid).unwrap_or_default() == "lsass.exe" {
89+
let process_name = get_process_name(pid).unwrap_or_default();
90+
91+
if process_name == "lsass.exe" {
8892
return Ok(pid);
93+
} else if process_name == "winlogon.exe" {
94+
fallback_pid = Some(pid);
8995
}
9096
}
91-
bail!("lsass.exe not found!")
97+
if let Some(pid) = fallback_pid {
98+
return Ok(pid);
99+
}
100+
bail!("Neither lsass.exe nor winlogon.exe found!")
92101
}
93102

94103
fn get_process_handle(pid: u32) -> Result<HANDLE> {
@@ -135,7 +144,7 @@ fn get_system_token(lsass_handle: HANDLE) -> Result<HANDLE> {
135144

136145
pub fn start_impersonate() -> Result<HANDLE> {
137146
enable_privilege()?;
138-
let pid = get_lsass_pid()?;
147+
let pid = get_system_process_pid()?;
139148
let lsass_handle = get_process_handle(pid)?;
140149
let duplicated_token = get_system_token(lsass_handle)?;
141150
close_handle(lsass_handle)?;

0 commit comments

Comments
 (0)