POST 数据漏洞文件执行任意后缀文件保存
: E+ r/ p. O/ T 漏洞文件/chart/php-ofc-library/ofc_upload_image.php
/ n. [; h4 _/ b5 K# B% J
: B& h9 e, W* d# I利用:
9 S8 z0 O- }0 B/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名# a$ n0 z& S s: L& [( O8 K3 ~- I
* `0 t8 ^- X' j) }) L3 b' u- {Post任意数据* R" S7 ]2 L" ~& U
保存位置http://localhost/chart/tmp-upload-images/hfy.php4 Z4 W4 b2 L# y" ~, m# D, \2 I
% W% C" E) F+ e& |( H
0 {! t/ c- L4 }最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~5 l' F, v1 c! Q) f4 ~5 S
+ u4 Z" f- @! u) l6 W" {
<?php2 z. v5 ~& w+ ^3 Z# p8 E6 [! a0 k
. R l4 Q1 o$ B% d) O) a+ Z" @
//
7 h+ f, p8 A4 \/ R; O// In Open Flash Chart -> save_image debug mode, you
- u, Q% p$ F6 C# l e( @// will see the 'echo' text in a new window.% s5 a M# T" S1 B: P/ o+ K4 w
//
4 U( Y, _. |) \' {% A! L$ ?! X
M6 {9 l) }, E, ]) a' r7 m, }, i/*4 D/ v; d/ _) M {
; W1 C+ \# K R$ Yprint_r( $_GET );7 Z7 C( u- v. h+ |; n8 T
print_r( $_POST );
& ~% o& H; t1 A8 g! Dprint_r( $_FILES );9 R! ~3 N, w, D% R
% e* X5 k7 R# z+ c6 f* lprint_r( $GLOBALS );# ]$ _- k! } \! D
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
( u3 u# B. S+ t: z; p: V7 ~; L2 a) W- C# R
*/
# G; e+ ^7 W+ `) z& P/ Z// default path for the image to be stored //, s7 P9 S: J; t, p4 R! F, l
$default_path = '../tmp-upload-images/';
* V$ o* k) c# G+ C$ H; X. a: O6 O
3 ?) w- K& X3 u& n+ nif (!file_exists($default_path)) mkdir($default_path, 0777, true); {1 o/ u1 {& Q6 ?* T
8 C9 E6 o& x9 ?/ g& ]) N
// full path to the saved image including filename // q. X7 E/ t: g$ q7 a% G
$destination = $default_path . basename( $_GET[ 'name' ] );
, Q7 L; W' a# _- E. ?( C% f' D0 Y7 B8 y2 S2 m; ]' b
echo 'Saving your image to: '. $destination;
0 y, w F: ^5 F// print_r( $_POST );( C9 Z6 V. O& {3 v
// print_r( $_SERVER );3 X3 ]: j Z' L1 i, g: U. h
// echo $HTTP_RAW_POST_DATA;" `) R. Z/ h9 d( T
1 ]& D- b7 w6 n! ]1 @. A
//5 N' q6 [6 e L& z: v3 C
// POST data is usually string data, but we are passing a RAW .png
* |. Z6 n: W9 N8 v( q7 |// so PHP is a bit confused and $_POST is empty. But it has saved9 y2 n2 G5 k$ H
// the raw bits into $HTTP_RAW_POST_DATA! [1 N( f. I& l! c7 F3 I0 h
//
$ R; M5 I% J* _) N% i7 m0 _: z" x$ J0 _; A" \& [& P0 ?$ u
$jfh = fopen($destination, 'w') or die("can't open file");
. q0 }) E# S" G% ?3 p" \* nfwrite($jfh, $HTTP_RAW_POST_DATA);
. T0 r0 ], ?1 m# qfclose($jfh);4 ~! p: n$ q8 p* p. G
9 s3 P* {8 V" e- \8 }7 n9 [) V1 s
//
: e% T* F4 j' B1 Y/ i// LOOK:. T) w# P7 D9 p6 k: w" \$ w
//
2 @# w* `6 F v" ]* E7 qexit();1 k2 l- E1 R( Y6 [, L |
//
: v8 s, S+ W! ^1 g1 v// PHP5:
9 \! j: k! r' f# H; ]% b//( D$ R& r1 a W4 N5 @9 d6 ~0 z
2 @7 a8 M. k' z5 a1 ? F
% M$ n9 ]9 _2 h0 D# W. v2 p) y// default path for the image to be stored //
- p: @5 S1 U8 r8 Z6 P9 _- @$default_path = 'tmp-upload-images/';
4 o# t n( G5 {- F! P
3 P# p) G! i' o( ^: Rif (!file_exists($default_path)) mkdir($default_path, 0777, true);' K2 r) ^. Y9 L- M i. Y
1 {8 \0 r! p5 N8 ^9 ^' L
// full path to the saved image including filename //
+ P( ?* g2 A7 K9 N+ `$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
0 X# K6 n* _. n; q* C! ] {% l9 h( i' o+ U7 j( O
// move the image into the specified directory //
, F d$ @% t7 L, S1 lif (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
) k6 s% Q: a* k, a3 P/ S: X) s echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";; ? @2 U- A. `
} else {
0 E5 x9 c5 T" g8 ~ U! x echo "FILE UPLOAD FAILED";5 D" m: N- j- j5 ?& V
}
G4 S) N. I$ f: m- ~7 I$ B* C
$ E. g5 w2 h4 P3 t1 m9 g% d) y6 E7 _
: M" h$ V6 ]0 m5 `5 I/ ?; L! L; I?>, G, w# u- W: q
/ Z2 U, z- r) W
" v: C# ^2 b# s6 b4 Z
$ W( F9 W& u. ]% c- b b
& U4 i0 T+ @- h' f! [
4 l+ V) s7 O+ N' w; O% y$ t* |; b5 N( K+ w) p! W
修复方案:
, [' D% n' j& C0 c2 c; p这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞
" w( ?4 ^9 G( G+ v6 [% M2 F" R, h* V- }
$ w) D* V8 s; M( c( G* y' ^; Z% ^4 v+ R# `
; m" A5 n; B5 J" }0 _0 j
|