POST 数据漏洞文件执行任意后缀文件保存
& R. S' ?3 r& z+ a 漏洞文件/chart/php-ofc-library/ofc_upload_image.php% {) J& k! }0 E- Y, D
! c6 V: O; U& C C% p利用:
( G, l/ S( H7 M6 j& i/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名" c1 @" X3 k3 b9 O- d
8 ?& I2 _# V5 x/ P1 EPost任意数据
3 X& r) V/ i% g+ U% A2 F7 `保存位置http://localhost/chart/tmp-upload-images/hfy.php
% N+ K0 ^+ ~6 Z. n9 P! t; m
( N1 n" b& {+ h1 n u* h) |1 w
; U( |# H+ i1 W2 p* l9 }) n最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~: q, B0 d; k7 E5 k3 g5 {( h
" x/ C9 s" b8 p' v) q6 `
<?php6 I3 }0 r' n, u) g1 U: j! W. }
; A9 ]; s! @( b0 |# V//
( ?5 @ k; |$ b// In Open Flash Chart -> save_image debug mode, you/ Q; x* ^2 L- v( u: t
// will see the 'echo' text in a new window.* |5 J+ B5 N! D' D/ ^
//
2 ?( R" i( [( l" m L6 {# c1 H% x# d% `0 L$ j3 _
/*: f/ N+ k8 i) t8 d) K
1 Q( Y' H- B- z& S% w1 n% xprint_r( $_GET );7 @+ m) P6 x0 E/ Q! p' T
print_r( $_POST );- X/ p" `+ p+ |( {( I4 T4 M$ Z6 |
print_r( $_FILES );
' v8 g0 S0 w( A% Y. K3 H. N, A' P
: _; [2 p( i4 Zprint_r( $GLOBALS );
L+ [, E* V" _& U7 ^( N' hprint_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
% }6 v7 M2 k F$ F" x
2 Y3 Y; b e8 E" Y; T3 |- }*/
5 l! p7 }) u' B% O$ G+ a5 J// default path for the image to be stored //
1 @: `4 W% o3 s) a# T6 Q+ \% @$default_path = '../tmp-upload-images/';
: ?6 l5 @6 G r- C4 v c7 ]9 j: U* m& w) j% Y
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
E2 b- w, R$ i3 M( ~' g: ]# V I: Q* f3 C) t
// full path to the saved image including filename //- |. H: ~0 Y" m4 T5 w$ t
$destination = $default_path . basename( $_GET[ 'name' ] );
. J. R( o, g. z5 [& w
' f* C& t+ Q! w7 f4 a/ H3 Eecho 'Saving your image to: '. $destination;6 V; O* p2 n; I6 X7 Z( D
// print_r( $_POST );
8 Q' n/ P/ I: p n& x$ P2 z// print_r( $_SERVER );
* X: L$ i7 G1 ~// echo $HTTP_RAW_POST_DATA;
9 v! ?! i% R3 _& K/ B; I9 D% d9 D; E6 _# l; m+ V# d4 |
//0 M( y0 R; c7 Q8 Z. \
// POST data is usually string data, but we are passing a RAW .png! K* g. d3 W8 t) ?) @+ X5 ]
// so PHP is a bit confused and $_POST is empty. But it has saved7 i* r6 B, ]+ x: [- P
// the raw bits into $HTTP_RAW_POST_DATA9 J( R' [9 `& t3 {0 S, N/ }
//
5 \) \0 i. [" \- N1 C/ T5 Q, E I- N- f# _
$jfh = fopen($destination, 'w') or die("can't open file");% i( ?0 ]8 y7 s& X! {
fwrite($jfh, $HTTP_RAW_POST_DATA);" g1 K k* |6 H' D9 v$ b) a8 j
fclose($jfh);# `% f2 f5 R5 T( l# L
/ R8 I' c7 ?, R//3 @9 L' D8 I! M: G
// LOOK:
) D( O* M! j7 G; L, H) Y//
8 S0 G- H' |$ ?; e& P9 bexit();( u t' p2 l$ n5 m
//8 y. c) [/ y8 g
// PHP5:2 U g) w) i( N3 N
//
8 O) \6 x* M% f- E+ r, F. x+ M# H9 r% {0 d4 `2 R( A
* ^/ b- @, P/ I' g
// default path for the image to be stored //
% _& Z1 h& r1 t7 X) Q$default_path = 'tmp-upload-images/';& `" F4 ~8 y8 v( D: f1 X, n
! g. Q7 O$ T z# R4 Vif (!file_exists($default_path)) mkdir($default_path, 0777, true);
! i- o7 N' w" H' ]# v# ^9 ~( E, S$ L- z x; _5 c
// full path to the saved image including filename /// K* V9 S$ a2 y. b2 j/ ?/ H
$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] ); 5 I. T' B; p" } O6 T
; B/ ^3 _# h0 Y* Q% o7 [- `
// move the image into the specified directory //
& f* \" T& R1 ~* D. n0 @) ?3 K! W, Gif (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {9 w% g+ k1 y; {, H& i" s
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";6 n+ u' Z# T$ E5 N- a' ?
} else {
- d4 I1 W! ]& B6 ?% }2 d echo "FILE UPLOAD FAILED";
# s% F/ W! ]1 g6 v, @4 O' A- ~}7 e7 O# k5 y3 y/ A: l1 Y
) q9 g" V* M; Z/ c/ S: r* I
& C) Z8 m! M6 h2 x1 |1 |?>
. G% E# |+ [0 U r" g% h" V" L
# [9 N5 x$ G3 E' D% W
% k1 s u, `3 N6 X# L
8 ^ |& r) O; Y2 a" H( M+ z9 ?/ G7 h) E7 N7 w) z9 c8 o0 i
$ m- M q! r+ v% T+ e0 w
' ?& y6 v2 _+ B, r7 F修复方案:
2 K4 y* J% g9 T, d3 P这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞
Z/ n8 O8 Z$ D/ A6 r$ h+ w; A, ]8 ]$ U8 B% r* N
% C2 J% d% Q7 g" x0 z& n3 ~; i: ?7 w! u" O& f7 p3 h$ U) r* a
/ u6 T1 Q7 b/ }
|