服务
考虑到很多服务也是开机启动的,因此服务也可以用来实现持久化。我们可以通过 SharPersist 工具的命令来实现
SharPersist -t service -c "C:\Windows\Tasks\Beacon.exe" -n "Update Services" -m add
我们也可以手动创建后门服务。
sc.exe create Service2 binPath= "C:\Windows\System32\calc.exe" start=auto
sc.exe start Service2
我们可以直接将 binPath 指向我们想要的可执行文件,例如 exe 载荷。但是需要注意的是,服务所用的 exe 可执行文件与一般的可执行文件有所不同,如果我们直接指向一般可执行文件,例如 exe 版的 CS 或 Metasploit 载荷,我们会遇到 The service did not respond to the start or control request in a timely fashion 报错,或者程序会在运行后很快退出。作为一个 workaround,我们可以使用具有进程注入功能的 Shellcode 加载器,即在程序退出之前迁移到其他进程中实现持久化。我们也可以直接生成服务二进制文件。