title: Decode chr() function?
body: <p>Hey guys been hitting hard on google and stackoverflow on this one...</p>
  
  <p>I got php files encoded with php chr() function here is some of the code:</p>
  
  <pre><code>   &lt;?php require_once chr(65).chr(100).chr(109).chr(105).chr(110).chr(67).chr(111).chr(110).chr(116).chr(114).chr(111).chr(108).chr(108).chr(101).chr(114).chr(46).chr(112).chr(104).chr(112);class WP_Amazonimportproducts_ImportController extends WP_Amazonimportproducts_AdminController{protected function _isAllowed(){return Mage::getSingleton(chr(97).chr(100).chr(109).chr(105).chr(110).chr(47).chr(115).chr(101).chr(115).chr(115).chr(105).chr(111).chr(110))-&gt;{"isAllowed"}(chr(99).chr(97).chr(116).chr(97).chr(108).chr(111).chr(103).chr(47).chr(97).chr(109).chr(97).chr(122).chr(111).chr(110).chr(105).chr(109).chr(112).chr(111).chr(114).chr(116).chr(112).chr(114).chr(111).chr(100).chr(117).chr(99).chr(116).chr(115).chr(47).chr(105).chr(109).chr(112).chr(111).chr(114).chr(116));}protected function _initImport(){$this-&gt;{"_title"}($this-&gt;{"__"}(chr(67).chr(97).chr(116).chr(97).chr(108).chr(111).chr(103)))-&gt;{"_title"}($this-&gt;{"__"}(chr(87).chr(80).chr(58).chr(32).chr(65).chr(109).chr(97).chr(122).chr(111).chr(110).chr(32).chr(73).chr(109).chr(112).chr(111).chr(114).chr(116)))-&gt;{"_title"}($this-&gt;{"__"}(chr(73).chr(109).chr(112).chr(111).chr(114).chr(116).chr(32).chr(80).chr(114).chr(111).chr(100).chr(117).chr(99).chr(116).chr(115)));return $this;}protected function _initProduct(){$   =Mage::getModel(chr(99).chr(97).chr(116).chr(97).chr(108).chr(111).chr(103).chr(47).chr(112).chr(114).chr(111).chr(100).chr(117).chr(99).chr(116));$    =Mage::getSingleton(chr(97).chr(100).chr(109).chr(105).chr(110).chr(47).chr(115).chr(101).chr(115).chr(115).chr(105).chr(111).chr(110))-&gt;{"getImportSettings"}();if (isset ($    [chr(105).chr(109).chr(112).chr(111).chr(114).chr(116).chr(95).chr(112).chr(97).chr(114).chr(97).chr(109).chr(115)][chr(99).chr(97).chr(116).chr(101).chr(103).chr(111).chr(114).chr(121).chr(95).chr(105).chr(100).chr(115)])){$   -&gt;{"setCategoryIds"}($    [chr(105).chr(109).chr(112).chr(111).chr(114).chr(116).chr(95).chr(112).chr(97).chr(114).chr(97).chr(109).chr(115)][chr(99).chr(97).chr(116).chr(101).chr(103).chr(111).chr(114).chr(121).chr(95).chr(105).chr(100).chr(115)]);
  </code></pre>
  
  <p>I have been trying to find a decoder as far I understand you can use ord() php function to decode it? I have found a script to encode text to chr(65) if it was possible to reverse it to make it decode php scripts encoded with chr(111).chr(65) it would be amazing I got few pages I need to decode and the only way I can think it will work if it can skip non chr(65) code so I can paste the whole page and decode it. What do you guys think? How can I decode it?</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Convert String To PHP ASCII in PHP chr() function&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;b&gt;Convert String To PHP ASCII in PHP chr() function:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
          &lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="get"&gt;
              &lt;textarea name="s" rows="20" cols="100"&gt;&lt;/textarea&gt;
              &lt;input type="submit"&gt;
          &lt;/form&gt;
          &lt;br /&gt;  
  
          &lt;?php
          $string = stripslashes($_GET['s']); 
          $chrstring = "";
          for ($i=0; $i &lt; strlen($string); $i++)
          {
              $chrstring .= "chr(" . ord(substr($string,$i,1)) . ")";
              $chrstring .= ($i==strlen($string)-1)?"":".";       
          }   
  
          $toscreenstring = htmlentities($string);
  
          echo "&lt;b&gt;Converted:&lt;/b&gt;&lt;br /&gt;$toscreenstring&lt;br /&gt;&lt;b&gt;To:&lt;/b&gt;&lt;br /&gt;$chrstring&lt;br /&gt;&lt;br /&gt;-"; 
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Edit!</strong> I have found a php script with similar function to decode this thing but it works on number only (with out chr(number).chr(number) and need to make it skip non chr(number) so it will be possible to paste the whole script and it will decode what needed.</p>
  
  <pre><code>   &lt;?php
  
     $charset = array(
          32 =&gt; ' ', 33 =&gt; '!', 34 =&gt; '"', 35 =&gt; '#', 36 =&gt; '$',
          37 =&gt; '%', 38 =&gt; '&amp;', 39 =&gt; "'", 40 =&gt; '(', 41 =&gt; ')',
          42 =&gt; '*', 43 =&gt; '+', 44 =&gt; ',', 45 =&gt; '-', 46 =&gt; '.',
          47 =&gt; '/', 48 =&gt; '0', 49 =&gt; '1', 50 =&gt; '2', 51 =&gt; '3',
          52 =&gt; '4', 53 =&gt; '5', 54 =&gt; '6', 55 =&gt; '7', 56 =&gt; '8',
          57 =&gt; '9', 58 =&gt; ':', 59 =&gt; ';', 60 =&gt; '&lt;', 61 =&gt; '=',
          62 =&gt; '&gt;', 63 =&gt; '?', 64 =&gt; '@', 65 =&gt; 'A', 66 =&gt; 'B',
          67 =&gt; 'C', 68 =&gt; 'D', 69 =&gt; 'E', 70 =&gt; 'F', 71 =&gt; 'G',
          72 =&gt; 'H', 73 =&gt; 'I', 74 =&gt; 'J', 75 =&gt; 'K', 76 =&gt; 'L',
          77 =&gt; 'M', 78 =&gt; 'N', 79 =&gt; 'O', 80 =&gt; 'P', 81 =&gt; 'Q',
          82 =&gt; 'R', 83 =&gt; 'S', 84 =&gt; 'T', 85 =&gt; 'U', 86 =&gt; 'V',
          87 =&gt; 'W', 88 =&gt; 'X', 89 =&gt; 'Y', 90 =&gt; 'Z', 91 =&gt; '[',
          92 =&gt; '\\', 93 =&gt; ']', 94 =&gt; '^', 95 =&gt; '_', 96 =&gt; '`',
          97 =&gt; 'a', 98 =&gt; 'b', 99 =&gt; 'c', 100 =&gt; 'd', 101 =&gt; 'e',
          102 =&gt; 'f', 103 =&gt; 'g', 104 =&gt; 'h', 105 =&gt; 'i', 106 =&gt; 'j',
          107 =&gt; 'k', 108 =&gt; 'l', 109 =&gt; 'm', 110 =&gt; 'n', 111 =&gt; 'o',
          112 =&gt; 'p', 113 =&gt; 'q', 114 =&gt; 'r', 115 =&gt; 's', 116 =&gt; 't',
          117 =&gt; 'u', 118 =&gt; 'v', 119 =&gt; 'w', 120 =&gt; 'x', 121 =&gt; 'y',
          122 =&gt; 'z', 123 =&gt; '{', 124 =&gt; '|', 125 =&gt; '}'
      );
  
       function fromNumber($number)
      {
          $string = '';
          while($number)
          {
              $value = substr($number, 0, 2);
              $number = substr($number, 2);
  
              if($value &lt; 32)
              {
                  $value .= substr($number, 0, 1);
                  $number = substr($number, 1);
              }
  
              $string .= $charset[ (int) $value];
          }
          return $string;
      }
  
   function fromString($string)
      {
          $number = '';
          foreach(str_split($string) as $char) $number .= ord($char);
          return $number;
      }
  
  
  $string = 'this is my test string to convert';
  
  $number = fromString($string);
  $string = fromNumber($number);
  
  
  ?&gt;
  </code></pre>