Jump to content

Best way of doing this?


newbtophp

Recommended Posts

I have some encoded code and if I change eval to $some, then add

$some= preg_replace('eval', 'echo', $some);

eval ($some); before ?>, I get the decoded.

 

So here and example encoded: (not functional)

 

<?php $_G="string"; eval($_G("string")); ?>

 

Heres how it would look if was to decode it: (example)

 

<?php $_G="string"; $some($_G("string"));  $some= preg_replace('eval', 'echo', $some); eval ($some); ?>

 

 

if you were to create a script to do so how would you do it?

 

I've tried and come up with:

 

<form action="index2.php" method='post'>

<textarea name='so' rows="8" cols="20"></textarea><br>


<input type='submit' name='submit' value='Submit'/><br>
</form>

<?php
$so = $_POST['so'];
$so = str_replace(?>', "", $so);
$so = str_replace('eval($_G', '$some($_G', $so);
$submit= $_POST['submit'];
if($so == "") echo "";
else {
    if($submit == "Submit") {
echo $so;
$some= preg_replace('eval', 'echo', $some);
eval ($some);
echo "?>\n";
    }
}
?>

 

Can anyone suggest a better way?, since the way Im trying is not functioning, Im using str replace to change the text.

 

Link to comment
https://forums.phpfreaks.com/topic/171305-best-way-of-doing-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.