본문 바로가기

[+] Information/[-] Web

역공학이 불가능한 php 인코더

제목 그대로 해당 소스로 php 소스를 인코딩 할 경우 그 결과물은 역공학이 불가능하다고 하네요.

전 아직 테스트 해보지 않아 정확한 결과는 보지 못하였으나, 제작자가 그리 말하니 일단은 믿는 수 밖에 ^^;

  1. <?php
  2. function rstr() //Random String Function
  3. {
  4.  $len=rand(3,6);
  5.  $chr='';
  6.  for($i=1;$i<=$len;$i++)
  7.  {
  8.   $chr.=rand(0,1) ? chr(rand(65,90)) : chr(rand(97,122));
  9.  }
  10.  return $chr;
  11. }
  12. function enjumble($data) //Custom Encoding + Base64 + gzinflate()
  13. {
  14.  for($i=0;$i<strlen($data);$i++)
  15.  {
  16.   $data[$i]=chr(ord($data[$i])+1);
  17.  }
  18.  return base64_encode(gzdeflate($data,9));
  19. }
  20. function striptag($in) //Remove '<?php' from initial code
  21. {
  22.  $pos = strpos($in,"<?php"); //to do: add support for short_tags
  23.  if(is_numeric($pos))
  24.  {
  25.   for($i=$pos;$i<=$pos+4 && strlen($in) >=5;$i++)
  26.   {
  27.   $in[$i]=' ';
  28.   }
  29.   return $in;
  30.  }
  31.  else
  32.  {
  33.  return $in;
  34.  }
  35. }
  36. function makeoutfile($str)
  37. { $funcname=rstr();
  38. $varname='$'.rstr();
  39. $template=
  40. "<?php function ".$funcname."($varname)
  41. {
  42. $varname=gzinflate(base64_decode($varname));
  43.  for(\$i=0;\$i<strlen($varname);\$i++)
  44.  {
  45. ".$varname."[\$i] = chr(ord(".$varname."[\$i])-1);
  46.  }
  47.  return $varname;
  48.  }eval($funcname(\"";
  49.   $str=enjumble($str);
  50.  $template = $template . $str."\"));?>";
  51.  return $template;
  52. }
  53. function main($argc,$argv)
  54. {
  55. $banner=
  56. "\n +-------------------------------------------------------------------+
  57.  |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
  58.  |+                                                                 +|
  59.  +____               _             _                    _           +|
  60. /  __ \             | |           | |                  (_)          +|  
  61. | /  \/  __ _  _ __ | |__   _   _ | |  __ _  _ __ ___   _  _ __    _+|_
  62. | |     / _` || '__|| '_ \ | | | || | / _` || '_ ` _ \ | || '_ \  / _ \
  63. | \__/\| (_| || |   | |_) || |_| || || (_| || | | | | || || | | ||  __/
  64.  \____/ \__,_||_|   |_.__/  \__, ||_| \__,_||_| |_| |_||_||_| |_| \___|
  65.  |+                         __/ |                                    +|  
  66.  |+                    Carbylamine PHP Encoder                      +|  
  67.  |+                           v0.1.1 Nightly                        +|
  68.  |+                                                                 +|
  69.  |+                                                                 +|
  70.  |+                      Coded by Prakhar Prasad                    +|
  71.  |+                        (prakharpd@gmail.com)                    +|
  72.  |+                                                                 +|
  73.  |+                                                                 +|
  74.  |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
  75.  +-------------------------------------------------------------------+\n\n";
  76. $usage="$banner Syntax: ".$_SERVER['PHP_SELF']." <file to encode> <output file>\n";
  77. if($argc==1) {echo $usage ; die();}
  78. if($argc>1) $file = $argv[1];
  79. if($argc>2) $outfile = $argv[2];
  80. if(empty($file) || empty($outfile)) { echo "Input/Output filename not entered!\n\n\x07" ;die();}
  81. if(!file_exists($file))
  82. {
  83. echo "$banner Error: Input file doesn't exist\n\n\x07";
  84. }
  85. else{
  86. $orginal_size=round(filesize($file)/1024,2);
  87. echo "$banner  Encoding : $file ($orginal_size KB) \n\n ";
  88. $output_filename=$outfile;
  89. $outfile=fopen($outfile,'w+');
  90. $file=fread(fopen($file,'r'),filesize($file));
  91. $outdata=makeoutfile(striptag($file));
  92. $newsize=round(strlen($outdata)/1024,2);
  93. echo " Compression : ".@round(100-(($newsize*100)/($orginal_size!=0?$orginal_size:1)),2)."%\n\n";
  94. if(!fwrite($outfile,$outdata))
  95. {
  96.  echo " Unable to write to $output_filename\n\n\x07";
  97. }
  98. else
  99. {
  100. echo "  Successfully Encoded! to $output_filename\n\n" ;
  101. }}}
  102. main($argc,$argv);
  103. ?>