Page 1 of 1

Does eval REALLY works???

Posted: Tue Dec 08, 2009 4:31 pm
by yankleber
I am working on a small obfuscation script using eval as the main engine. Everything was doing fine when I bumped to a problem. Look at the following code:

Code: Select all

 
<?php
$dollar = "\$";
eval ("for($dollar"."z=0;".$dollar."z<=10000;".$dollar."z++".")");
?>
 
Instead to run the code, it spits out the following error message:

Parse error: parse error, unexpected $end in c:\www\apache\htdocs\bcs_eval\wtf.php(6) : eval()'d code on line 1

Why doesn't eval evaluate it??? Any idea?

8O

Re: Does eval REALLY works???

Posted: Tue Dec 08, 2009 4:43 pm
by Christopher
Because "for($dollar"."z=0;".$dollar."z<=10000;".$dollar."z++".")" is not a valid statement. It needs to be valid PHP code.What's in the loop?

Re: Does eval REALLY works???

Posted: Tue Dec 08, 2009 4:46 pm
by AbraCadaver
That's not complete code. Put this in a PHP file and run it, you'll get the same parse error:

Code: Select all

for($z=0;$z<=10000;$z++)
Normally for loops have { and } yes?

Re: Does eval REALLY works???

Posted: Tue Dec 08, 2009 5:33 pm
by yankleber
Yes, you both are right! I didnt get that because I was evaluating my code and testing it for parsing problems line by line...
I added the ; after that and it worked.

Thank you for putting a light over that - I am over this project for so many time that sometimes small things passes thru!

:oops: