POST 数据漏洞文件执行任意后缀文件保存
% e( j* V6 J7 |# g* H8 |2 [ 漏洞文件/chart/php-ofc-library/ofc_upload_image.php: C$ z2 i$ j8 U# g: B7 o
9 b1 g: o5 M: k* ]利用:+ x' |) K6 b! A! w! j% l
/chart/php-ofc-library/ofc_upload_image.php?name=hfy.php hfy.php 文件名
9 g# b$ W: ^+ a. ~' s& O2 S( `; y* x* g( \1 j1 M* @
Post任意数据9 u0 ^3 Z3 W2 t2 u
保存位置http://localhost/chart/tmp-upload-images/hfy.php/ Q# W9 c/ N+ |$ q9 k7 Q
' ~& B$ ?; H% a+ c8 s7 |0 i5 j
1 |" v% n2 s8 g5 E& H$ Y
最新版wss漏洞文件,即使是收费版本也有的,在新浪商店部署的demo~2 j s( N8 ~2 b+ }6 m% Q. O
' b2 q [( _( W6 d: u, m
<?php
1 M/ m' d2 O. V2 w5 A7 @) G
8 o$ A: ~ n, a( y//" H( C" }; \/ ^* r7 d- a( b
// In Open Flash Chart -> save_image debug mode, you+ n1 s( S) t% h1 |6 k z- |
// will see the 'echo' text in a new window.+ U: \5 H" Y' H
//
$ s9 F1 w7 c' n8 c+ s$ S1 ]8 t3 D% `, K5 T# S
/*
% j8 V2 d: ^7 x' ~' q/ E) w6 x1 D% h
print_r( $_GET );
. j# y B N' ^4 l- bprint_r( $_POST );% j6 Q, Y5 [- `; P
print_r( $_FILES ); ~) Z( W9 W! G5 m1 L
0 J& f, _) Z# m0 h5 f0 M: _ dprint_r( $GLOBALS );3 Z& C, n* ?$ T! Z
print_r( $GLOBALS["HTTP_RAW_POST_DATA"] );
' t3 T+ C; G0 E+ b! ^
9 J6 A; x, c4 d5 ^- r- \% R*/! E& @2 [2 Y) C& p
// default path for the image to be stored //- a% _, G4 z1 O8 S
$default_path = '../tmp-upload-images/';' r$ ~- {7 t) R2 G
; o3 f/ Y4 T: k! H
if (!file_exists($default_path)) mkdir($default_path, 0777, true);
) q C4 G3 a- O Y! m* p% ~
6 n' R a( X' X, e8 S5 v# Q// full path to the saved image including filename //
: P- U* {% y$ s7 H; b$ Y, A) U$destination = $default_path . basename( $_GET[ 'name' ] );
. x6 G9 X& X: f6 g g6 G, C u
2 h1 l c3 i3 \* V0 t wecho 'Saving your image to: '. $destination;2 _6 S' Y& E) U7 X
// print_r( $_POST );; z9 _% d0 ]6 h4 s7 Z) [
// print_r( $_SERVER );3 _! C2 T6 U' j T) L/ S% e
// echo $HTTP_RAW_POST_DATA;
* h3 w0 q+ S3 M' [8 O; O; A
" c# ]' Y F7 M4 v# n- r8 Q//! J/ N6 `7 F# a( K
// POST data is usually string data, but we are passing a RAW .png
/ ]$ X& }2 e- v! \1 s: T3 _// so PHP is a bit confused and $_POST is empty. But it has saved
- u4 L# I ]& j0 |9 ~: i* m+ y// the raw bits into $HTTP_RAW_POST_DATA. L* f+ l/ n1 F3 b2 X
//( h$ ~# [- b0 p6 }
, A4 ~: W0 c8 a, b u& u$jfh = fopen($destination, 'w') or die("can't open file");7 k* l. [ `8 I
fwrite($jfh, $HTTP_RAW_POST_DATA); H Q, p% d6 Q( E$ [5 T
fclose($jfh);
6 I9 K8 J5 t; ~" L5 [ H
" T, A9 Z ^* w8 g% z/ ~//
/ E5 c4 c; ^. n// LOOK:0 w9 s1 [* c0 D5 ?
//* Y5 u5 ^% M1 E- z9 e( }
exit();6 [$ V5 X( C n* r$ _ a$ H
//. q% M; J0 d, u* l7 h# A% b5 J
// PHP5:
" {; x/ _; h+ V- H( [, {) z//6 H& n0 J' u4 G, D
$ W, l8 |2 j# W: C) |$ }4 Y- R4 i
5 A7 {6 A3 s9 P+ |, @ t// default path for the image to be stored //) e& c* I% i1 F3 h+ |
$default_path = 'tmp-upload-images/';
E, K* b! q4 H# C3 e$ O1 |0 @- @1 Z- Y8 T" _) o( o& g; y# j4 x' e7 Q
if (!file_exists($default_path)) mkdir($default_path, 0777, true);) S# t8 s6 B' j. D( F
% [$ j+ Z) y6 J f$ U
// full path to the saved image including filename //
9 W- V0 t" `5 X: _: `9 L* q$destination = $default_path . basename( $_FILES[ 'Filedata' ][ 'name' ] ); 5 l; \2 ~2 ~! H' \
% g C- Q6 ]) `- ^
// move the image into the specified directory //; o# s% h& l$ y/ r& ~! k
if (move_uploaded_file($_FILES[ 'Filedata' ][ 'tmp_name' ], $destination)) {
0 z# [8 C: Z; G7 x" z( ?% t; F echo "The file " . basename( $_FILES[ 'Filedata' ][ 'name' ] ) . " has been uploaded;";
$ ?7 D, b* u5 N j, a- M} else { J+ N) ^, {: P% W. G* C
echo "FILE UPLOAD FAILED";
. Y) r8 m" s( x; @" s, ~5 Q( T}
`: t- B. O! [9 T7 b5 f
5 r6 o" _* N- C k" o8 f d+ _0 h. W& u; g4 j: r/ o/ v5 R
?>$ O( x6 E7 m1 l; W; o
0 ]7 V, E% N% b4 o; l6 M( H- Q0 P# ?: E# A+ _' _6 L
: p4 p4 T, L6 V: {
5 R# P% i4 J/ R% }( d7 Q5 ]# s
! P4 l0 g) C; X* b+ r
; i' [" J( m. S6 T1 t5 j% ?: ]+ l修复方案: ' b0 ~; K6 \2 X& t
这个漏洞文件就是个杯具,怎么破,加权限验证,后缀等验证~,自己搞
" V- c4 V4 S+ n* E2 Q. t- J
; v8 J- @/ R M: w3 K) F2 _0 l8 ?; \3 K
, s3 E% e4 R: o* O# u
! p& K& y1 |. _' ~* ] |