Does eval REALLY works???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yankleber
Forum Newbie
Posts: 4
Joined: Sun Dec 06, 2009 11:31 am

Does eval REALLY works???

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Does eval REALLY works???

Post 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?
(#10850)
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Does eval REALLY works???

Post 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?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
yankleber
Forum Newbie
Posts: 4
Joined: Sun Dec 06, 2009 11:31 am

Re: Does eval REALLY works???

Post 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:
Post Reply