gpt4 book ai didi

windows - 如何找出谁在运行 runas 应用程序?

转载 作者:可可西里 更新时间:2023-11-01 14:23:15 24 4
gpt4 key购买 nike

背景:

在我的组织中,有一个应用程序用于某些关键功能,但它只有在以特定用户身份运行时才能发挥最佳作用。

原因是应用程序将其大量配置存储为本地用户 session ,因此它成为多用户噩梦,这意味着我们不得不重复大量工作。

我们已经分配了一个用户来运行该应用程序,并通过设置 runas 桌面快捷方式找到了解决方案。问题是我们发现应用程序无法同时运行超过一次。它只允许每个并发用户运行 1 个实例。

我用于应用程序的快捷方式代码:

C:\Windows\System32\runas.exe /user:mydomain\runas_user /savecreds "C:\Program Files\MyApp\MyApp.exe"

因此,我一直在尝试确定如何查看当前正在使用“runas”应用程序的用户,以便让他们优雅地关闭它。任务管理器仅在用户名中显示“runas_user”,但我认为必须有某种方法来确定谁运行它或哪个用户 session 正在查看它。

问题:

有什么方法可以找出(最好使用 powershell 或其他脚本)当前正在运行该应用程序的用户?

最佳答案

Windows 安全事件日志应该显示这一点。所有 Windows 2008+ 身份验证事件都是事件 ID 4624(通过)或 4625(失败)。将其与登录类型相结合应该可以满足您的需求。

关于登录类型的大量详细信息来自 this PDF在 sans.org 上(大约从第 10 页开始)。我认为您最感兴趣的部分是“3.7 NewCredentials”:

Using RunAs command to start a program under a different user account with the /netonly switch, Windows records a logon/logoff event with logon type 9. When starting a program with RunAs using /netonly, the program executes on the local computer as the user currently logged on as but for any connections to other computers on the network, Windows connects to those computers using the account specified on the RunAs command. Without /netonly Windows runs the program on the local computer and on the network as the specified user and records the logon event with logon type 2

使用 PowerShell 获取事件 ID 和登录类型的快速而肮脏的方法:

$recentSecLog = 
Get-EventLog -LogName Security -Newest 1000 | Where {$_.EventID -match "4624|4625"}

$recentSecLog | Where {$_.message -match "Logon\sType:\s+9"}

关于windows - 如何找出谁在运行 runas 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37464349/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com