Geek magazine hacker daily blog

We do the self-extracting archive or sections in PHP files

Only one thing — stupid FTP of some hosters induced to write this code me. No, files are uploaded with maximum speed, but here between the end of loading of one file and the beginning of loading of the following passes seconds 30. As I suffer from a crap nowI impose and I put dzhomla in shock quantities, loading of 5000+ files leads to a reading of a habra and a guglrider to holes that however too is unhealthy. With the purpose to correct siyo annoying omission it is also written small nakolenochny skriptik.

Skriptik as it is known piece such that him not only on the server, but also from the console it is possible to start, so it is necessary to provide operability of both options. For determination of the console isset ($argv) is used Actually code of packaging and unpacking is not interesting. And here on what I would like to pay attention of %username of % so to that how exactly the packer is organized. For this purpose I tell about one function and one constant about which not only school students and Hindus do not know.

It is function __ compiler_halt and a constant __ COMPILER_HALT_OFFSET __, both are entered into PHP since 5.1 When parsing the file if php comes across on __ compiler_halt (); that it completes parsing and exposes in __ COMPILER_HALT_OFFSET __ number of the byte following a semicolon after function name It is important to understand that any?> it is not required after this construction any more What does it give us? And it gives us the chance to store any rubbish random data in our php a code And these data very easily are read out: file_get_contents (__FILE__,null,null,__COMPILER_HALT_OFFSET__); If it to use the file it turns out broken into 2 sections — section of a code and section of data

The packer contains in code section a packaging code, and in section of data an unpacking code Raspakovshchik in section of a code supports himself favourite, and in section of data — zip archive with data

well, for today I will ask to popinat all this that I wanted to tell unless breaking traditions legs for jambs in the first post on Habré, otherwise will be late :)

This article is a translation of the original post at geektimes.ru/post/84197/
If you have any questions regarding the material covered in the article above, please, contact the original author of the post.
If you have any complaints about this article or you want this article to be deleted, please, drop an email here: sysmagazine.com@gmail.com.

We believe that the knowledge, which is available at the most popular Russian IT blog geektimes.ru, should be accessed by everyone, even though it is poorly translated.
Shared knowledge makes the world better.
Best wishes.