📜 ⬆️ ⬇️

Encryption of a separate part of the PHP script

Many of those who program in PHP, faced with the need to encrypt their scripts in bytecode to transfer to the side. Thank God, nowadays there is a huge assortment of PHP Encoders, - as they say, for every taste and color!

We in our work faced a non-trivial task. It was necessary to hide only a certain part of the code, a function whose content no one should see but us.

At the same time, the entire file cannot be encrypted, since everything except this function should be visible, so that the technical specialists of the receiving party are convinced that there is no “crime” in the script. The function cannot be moved to a separate file either, because we have to be convinced that the md5 of the entire code has remained unchanged, which means that confidence in the invariance of the original form of both the encrypted and visible part of the script is necessary.
')
What to do? The first thing that came to mind was the so-called obfuscators, that is, the “tangles” of the code. At the same time, such code can be loaded without the need of additional loader modules for PHP, which is a plus. The downside is that even the most fierce obfuscator, which was found, broke down step by step within 15-20 minutes without undue haste.

Meanwhile, the good old Zend Encoder 3.6 was gathering dust on the shelf. It is clear that the encoder part of the script is not encrypted, but the task required a solution. If you look at the resulting encrypted file, you can find some part of the PHP code at the beginning of each file, namely:

<? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  1. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  2. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  3. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  4. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  5. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  6. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  7. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  8. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  9. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  10. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  11. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  12. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  13. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  14. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  15. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  16. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  17. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
  18. <? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .
<? php @ Zend ; 3272 ; /* This is not a text file ! */ print "\n" ; print "\n" ; print "&# 38 ; lt ; h1 > Zend Optimizer not installed < /h1 > "; print "This file was encoded by the Zend Encoder / Zend SafeGuard Suite\n"; print "In order to run it, please install the freely available Zend Optimizer, version 2.1.0 or later.\n"; print " < h2 > What is the Zend Optimizer? < /h2 > "; print < < < EOM The Zend Optimizer is one of the most popular PHP plugins for performance-improvement , and has been freely available since the early days of PHP 4 . It improves performance by taking PHP ' s intermediate code through multiple Optimization Passes , which replace inefficient code patterns with efficient code blocks . The replacement code blocks perform exactly the same operations as the original code , only faster . In addition to performance-improvement , the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite . The Zend Optimizer is a freely-available product from Zend Technologies . Zend Technologies is the company that develops the scripting engine of PHP , also known as the Zend Engine . EOM ; print "\n" ; exit (); ? > * This source code was highlighted with Source Code Highlighter .


This piece is created in case Zend Optimizer is not installed on the server, and when downloading any encrypted file, it declares to the whole world that it’s time to think about changing the system administrator :). But we were more attracted to the other. What is this mysterious? @Zend; \ n 3272; "in the first lines of the script? It was experimentally established that 3272 is the number of bytes enclosed between the lines “/ * This is not a text file! * / "And" exit (); "multiplied by two. In this case, constructions such as "\ n" and "<<< EOM" are taken as 1 byte. Is the meaning clear? Zend Optimizer loader simply skips the Nth number of bytes at the beginning of the file, and then executes the encrypted bytecode.

Then the task was reduced to placing the main (“visible”) code in place of this Zend Encoder's curtain and writing a loader that would execute the “visible” script after the main encrypted one.

The result was quite a simple file:
  1. function Secret () {
  2. // our secret function
  3. }
  4. // loader of the "visible" script:
  5. $ script = "" ;
  6. $ file = file ($ _ SERVER [ "script_FILENAME" ]);
  7. foreach ($ file as $ k => $ v) {
  8. if ($ k> = 3) {
  9. $ script. = $ v;
  10. if (substr ($ v, 0, 7) == "exit ();" ) break ;
  11. }
  12. }
  13. eval ($ script);
  14. exit;
* This source code was highlighted with Source Code Highlighter .


Next, we encrypt this file and instead of the Encoder stub we set the script we need.

It remains only to count the number of bytes in our “visible” script in order to correctly set the value for Zend Optimizer in the second line of the file (after “@ Zend”). It was too lazy to calculate it manually, so they wrote another script with two cycles: in the first cycle, a certain number of copies of the file were created with different “near-truthful” values ​​of bytes, and in the second, all these scripts were jerked by wget. A script with the correct value will return the 200th header instead of the 500th.

All is ready. The resulting file contains the "visible" part of the script and the bytecode. If the server is configured with the Zend Optimizer module, then when you call the script, its encrypted part will be executed first, and then the one that we do not hide. In some commercial tasks it is really very necessary.

Source: https://habr.com/ru/post/70372/


All Articles