TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Tips & Tricks (http://www.talkphp.com/tips-tricks/)
-   -   eval remake (http://www.talkphp.com/tips-tricks/2667-eval-remake.html)

TlcAndres 04-20-2008 09:54 PM

eval remake
 
A bit of a challenge to storm up the head I suppose.

PHP Code:

<?php

 rep_eval
('
     $i = 0;
      for($v = $i;$v < 100;++$v){
       echo($v);
      }
'
);
?>

Basically is to get this code or any other php code to run WITHOUT using eval() or any built in php functions to run php code (though I think eval() is the only one);

sjaq 04-21-2008 06:13 AM

PHP Code:

<?php 

    
function rep_eval($str) {
        
$f fopen('./tmp.php''w');
        
fwrite($f'<?php '$str ' ?>');
        
fclose($f);
        
        require 
'./tmp.php';
        
        
unlink('./tmp.php');
    }

    
rep_eval('
         $i = 0;
        for($v = $i;$v < 100;++$v){ 
           echo($v); 
        }
    '
);
    
?>


Kalle 05-23-2008 10:41 AM

If not using sjag's example by temp files then the only thing I really can think of is to use the tokenizer extension for PHP and then make your own executor which could be big ;)


All times are GMT. The time now is 02:01 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0