POST 数据漏洞文件执行任意后缀文件保存
" G' n+ _4 I$ d 漏洞文件/chart/php-ofc-library/ofc_upload_image.php& i f- w) V. v
/ [' L; g$ J5 W4 k" q7 _& w
利用:
' s. d7 U8 g, f/ ]/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名+ b' Z2 u/ S# }- p
* w1 U. a2 [5 @; C: V( |$ c& bPost任意数据0 |, T, o1 U% B" I& `
保存位置http://localhost/chart/tmp-upload-images/hfy.php) W+ J* X5 S1 }
* T: h) q- S2 ?9 ]8 ]8 ^
# h) e4 {$ {3 G; S. \/ r, b最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~% J: H1 q6 I( X* S* R% i
* \' \2 w+ p$ {# M
<?php+ s5 N4 z4 h) P
1 S% L# ]* S3 H6 |
//
- h( N& X U, v# C$ d! J' y// In Open Flash Chart -> save_image debug mode, you
3 X* } V0 v* F% H6 y5 z& E// will see the 'echo' text in a new window.2 w" p# N* R k7 O }! Y* j
//
! `/ r, Q) b4 R* V
, D" E Q# L3 k/*
" L, J4 d' ?* u4 v6 z8 v: X+ }& k* J) T9 g
print_r( $_GET );
0 K8 `; _$ B4 N* ^print_r( $_POST );) f# e" b; C8 [: R! ~2 K
print_r( $_FILES );
9 f) w9 T7 u" k& L$ K8 l- {) ~' f G( Z# U
print_r( $GLOBALS ); O( p; n1 F5 z) Y% m
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );4 G9 K! [) y& S Q+ a, ]% e9 ~
7 u" I$ {# r5 ]" A6 T& ^" E. t) X*/! j: V' U: @' v5 w
// default path for the image to be stored //$ o, {- A% b; I4 A
$default_path = '../tmp-upload-images/';* _8 m6 y1 t" `9 M2 j
/ b/ p' A% `- n j
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
: V: K" m- s- f5 R6 x8 Y. k, ?
0 \1 V: d) ?6 w$ y( {: |5 N// full path to the saved image including filename //
% t/ k& V9 y5 S- p) H/ ^8 _$destination = $default_path . basename( $_GET[ 'name' ] ); 8 r2 `8 Y* |1 f' w) f
* d" B0 W( m% ~2 oecho 'Saving your image to: '. $destination;2 N5 n1 F$ } b/ E+ ]& z1 c
// print_r( $_POST );
/ A4 v# n0 Y0 L" m* w// print_r( $_SERVER );8 }8 l0 Q! Y; X: D; H8 x3 x$ R. p1 M) e
// echo $HTTP_RAW_POST_DATA;1 f4 [0 B7 X1 H# F$ `; I8 _1 L( q/ j
, o; D* P( B$ D
/// H6 B# V- W: {" @- t$ n4 R
// POST data is usually string data, but we are passing a RAW .png
' J; s5 `& J( p4 {9 @/ F; G# O// so PHP is a bit confused and $_POST is empty. But it has saved
2 j: q6 Y$ u! a3 d+ U, j// the raw bits into $HTTP_RAW_POST_DATA
0 g7 _( ]" p9 G5 }//
$ t4 N3 }9 ]8 ]3 v- T# S- M7 @* J5 f# n
$jfh = fopen($destination, 'w') or die("can't open file");
7 O' p# m! z4 i# K8 h. t0 wfwrite($jfh, $HTTP_RAW_POST_DATA);
& Q/ S, D3 T$ [fclose($jfh);4 k/ Q' U5 V3 I: r
4 g, Z- d3 [- b5 @* w6 d8 K. |
//3 x& J9 H% p7 P7 V! P8 _5 t
// LOOK:( r( C5 p4 N' N6 A8 f. W# A
//5 B$ V( D$ I+ s2 v" o
exit(); M& D0 ~: ]1 J P4 x
//
5 P! D7 u0 o! R' ?// PHP5:5 G- J! s# u+ c5 B2 r5 F, l4 Y6 ]
// r( F4 c6 Z5 O! a: n4 t* z
; [9 `# |' Q4 l7 D5 a; V1 Z% N
. m3 t# p4 w7 b' }. X! U, A, j// default path for the image to be stored //' X \+ N( F# e( b
$default_path = 'tmp-upload-images/';
' ^( e( g3 o: K6 j
* z6 D. g3 d9 J0 v$ oif (!file_exists($default_path)) mkdir($default_path, 0777, true);: G0 a/ V" C6 O
2 d, }$ J9 l0 U" \5 y// full path to the saved image including filename //
; i; h/ H0 P# ]3 O8 N7 i7 I$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
( @" `' `( n% ^! u3 B
D6 o% u2 j9 {7 ]1 [// move the image into the specified directory //( j" R# T( R& B4 N# k9 I* D
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
' [$ f; z3 o, @5 M echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";9 l% \+ s( O' A0 ^6 l
} else {
, l% F5 p3 ]# m, q5 V echo "FILE UPLOAD FAILED";
T0 U9 a3 L8 W* c3 e}$ c: j' [: x9 A, Z8 P+ w- m
% t( H" O+ r: g+ W3 ]: f7 D
4 O1 H/ O& j8 I* Q
?>
- ?# i* I$ ?9 l4 O( ^4 a6 }+ c/ X* c
$ R* j) ~5 a: m
# [6 v& u2 k9 V" P# e0 O
. X6 f4 c4 k4 A5 U ~3 ~- J: ~! F B' m* e
, |' i) C9 ]7 _2 ^5 E修复方案: . y# b# U- B! k
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞
L& H1 {3 R* f+ c3 I6 V+ l9 B' A/ E, \
( h: w% ^1 L! V
4 F1 A3 k' v% ]$ T4 D# `
. h- i7 ?$ T _4 Q& \4 Q( `! ^8 g, Y
|