Skip to main content

基于 Windows 的其他持久化技术


主机账户


PowerShell 侧写


每当用户运行 PowerShell.exe 的时候,PowerShell 侧写文件会被加载。我们可以通过执行命令 $Profile | select* 来查询所有的 PowerShell 侧写,共有 4 个可能的位置:

image.png

C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
C:\Users\<用户名>\Documents\WindowsPowerShell\profile.ps1
C:\Users\<用户名>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

但是,显示出来的位置并不一定有现存的 profile.ps1 文件,我们可以自己新建一个。考虑到用户 serveradm 对 Web02 具有本地管理员权限,所以我们可以来到 AllUsersAllHosts 所对应的侧写目录:

image.png

为了验证概念,我们在侧写中运行 calc.exe,然后移动到该目录下。运行一个新的 PowerShell 进程,会发现计算器弹出来了。

image.png

终端侧写