Jump to content

Poor man's PHP Compiler


Fordiman

Recommended Posts

I'm currently working on a way to "compile" php scripts in Win32 in the following way.

 

Current target:

php_cli.bin - modified, compiled version of php_cli.c that will look in its own windows resources (PHPScript|1|1033) for the script to execute. Default CLI settings (no execution time limit, 32M Ram use) and the php_cli.ini will also be embedded. Optionally, the php(4|5)ts.dll (UPX --best compressed, about 1M in size) can be embedded for total portability. The .bin will be compiled for stealth (Set for Win32 GUI) mode, so Win API calls can be made to produce output without having to have an ugly console window.

 

The "compilation" process is simply insertion of the target script into a copy of the CLI.

 

Future targets:

Default script resource to PHPScript|index.php|1033 and compile in an fopen wrapper that allows for embedding and inclusion of multiple PHP scripts (ie: win32.resource://otherfile.php ).

Default gzip -9 compression of internal scripts to deter (not so much prevent) end-user tampering.

 

Anyway, any tips anyone can pass my way would be great, especially in using gcc/gpp as my compiler for php under Win32 (I just don't have the cashish for VS).

Link to comment
Share on other sites

  • 4 weeks later...

UPDATE:

I've written the PHP extension to allow for opening resources as files in PHP (called resopen, resread, etc. For not-yourself files, you can even write resources via a simulated stream interface, but that's a memory hog for large files. I may work on self-rewriteing, but I wouldn't count on it.)

 

Additionally, using a bit of code from Back Oriface 2000, I've managed to get PHP to load its DLLs from it's own resources (Resource type: DLLDATA).

 

The next step is to have php bootstrap from win32.res://self/phpscript/1/1033, and to write an fopen wrapper (into php_peres.dll) so that resource files can be accessed with the existing file-handling functions.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.