Giter VIP home page Giter VIP logo

Comments (31)

multiOTP avatar multiOTP commented on June 21, 2024 2

Hello Acuna,
There is an other approach: take the legacy PHP (7.x for example), then pack everything in a small virtual box in a single .EXE. Enigma Virtual Box (http://enigmaprotector.com/en/downloads.html) is a freeware that will do that for you very nicely.
In order to launch php.exe with the choosen PHP file, you will have to pack a launcher, because you can only tell Enigma to launch an EXE without parameter, and launching only php.exe will not be very useful. But it's not a big deal, it takes less than 50 lines in C++ to do the job, something like this:

/* Licence: LGPGL
 * Project: http://www.multiotp.net/
 * (c) 12.2016 SysCo systemes de communication sa
 */
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <string>
#include <iostream>

#define SOFTWARE    "LAUNCHER"
#define VER_NUMBER  "1.0"
#define VER_DATE    "2016-12-08"

int _tmain(int argc, _TCHAR* argv[])
{
	std::string my_arg = argv[0];
	my_arg = my_arg + "\\..\\";

	const char* my_arg_char = my_arg.c_str();

	char basePath[255] = "";
	_fullpath(basePath, my_arg_char, sizeof(basePath));

	std::string run_software = "";
	run_software = basePath + run_software + "php.exe " + basePath + "launcher.php";

	for (int a = 1; a < argc; a = a + 1) {
	    run_software = run_software + " \"" + argv[a] + "\"";
	}

	const char* run_software_char = run_software.c_str();

	return system(run_software_char);
}

We use this approach (among others) to create a command line version of our tool that works under window.

Regards,
Andre

from bamcompile.

 avatar commented on June 21, 2024 1

@multiOTP Thanks for your answer. It's interesting solution. But well, I think there's no need to install a virtual machine simply to compile some scripts. So I wrote a simple and light-weight PHP compiler, that supports PHP 5.6, makes executables from PHP files and working from console. I've upload it to SF less than a minute ago. You can be the first tester ;) Here is it: https://sourceforge.net/projects/phpc/

from bamcompile.

 avatar commented on June 21, 2024 1

@xZero707 wow, I'm glad to see you so much!) Yep, seems so) Yes, I wrote and own the only one working PHP compiler at this days. But I don't publish its sources yet because it needs more and more tests before. So at this days it compiles code to batches and makes an executables. The problem is that this files can be decompiled. It's not so easy, but it's really, because now it's a pseudo-bytecode, not a real one. It's simple using my own simple obfuscator and launcing it via PHP server which installing via SFX archives. I'm planning to make a pure bytecode compiler using a pure PHP bytecode low-lewer compiler like your Bamcompiler, but it needs to hard-digging in PHP sources, but unfortunately I have no free time to make it and I'm alone in it now( There's all new at this days. But I'll love if you have a some time to spend it to this, because my one is a crap like simple batches which simply launch the code on server, that's all what it make now. Now I'm implementing the version which do not use Windows batches, written on pure C and have a PHP server embedded using your embedder (thank you so much for it, it's really helps me a lot), so I've made many PHP builds with it and made some pool requests to them either, but I have a problem with adding an icons to file. It working with compiled PHP, but final app is crashing if it have an icon. So now I discontinued this project, because I've my own crunch which is working. It's not what I wanted to see, but it solved my problem. It's shortly)

from bamcompile.

multiOTP avatar multiOTP commented on June 21, 2024

Sounds good, but what about extensions support ?
Regards,

from bamcompile.

 avatar commented on June 21, 2024

Yeah) Ah, sorry, there's no extentions support, only PHP compiling, because it uses BLENC for file encode and packed it to the Windows batches. I don't know any other solution to make it without using batches.

from bamcompile.

multiOTP avatar multiOTP commented on June 21, 2024

Thanks for your feedback. No problem, I keep my virtual machine for the extensions.
Regards,

from bamcompile.

 avatar commented on June 21, 2024

@multiOTP hello! Can I ask you, which extensions do you use? Are you mean its simply adding to the php.ini?

from bamcompile.

multiOTP avatar multiOTP commented on June 21, 2024

Hello,
Here are actually the extensions I'm using for our project, they are simply added in the php.ini
extension=php_gd2.dll
extension=php_gmp.dll
extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
extension=php_openssl.dll
extension=php_sockets.dll

For some other projects (which are protected with SourceGuardian), the free following additional extension is also activated (here the name for PHP 5.6):
extension=ixed.5.6.win

Best regards,

from bamcompile.

 avatar commented on June 21, 2024

Ah! Ahah, I thought that you mean switching it on the fly to your code. It's not my PHPc feature, it's simply native PHP item, you can add your extentions to the php.ini (it installed in C:\PHP automatically with PHPc install). I think it'll be more simle and lightweight than use a VM :/

from bamcompile.

multiOTP avatar multiOTP commented on June 21, 2024

Hello, sure, but in this case, after launching the program, it will create a C:\PHP, which means you need admin access on the C: drive of the machine, right ?

from bamcompile.

 avatar commented on June 21, 2024

Sorry, I'm writing from another PC) Well, it's demands an administrator manifest when installs itself, because it might be installed in Program Files folder eg. But even it requires a PHP installed for all scripts, which is compiled by PHPc, it uses an another installer, which is loaded automatically during install. It doesn't requires an administrator manifest, because it installed simply on C drive, not Program Files folder. But its installer is simply WinRAR SFX archive, so you can simply open it via archive using WinRAR for.

from bamcompile.

multiOTP avatar multiOTP commented on June 21, 2024

Hello,
I tried, but I have the following error: PHP Fatal error: blenc_compile: Validation of script 'D:\Program Files (x86)\PHPc\phpc.dll' failed, cannot execute. in Unknown on line 0
My test file called test.php has three lines:

<?php
phpinfo();
?>

Any suggestion ?
Regards,

from bamcompile.

 avatar commented on June 21, 2024

Hello. Thanks a lot for test, seems it can't find a keyfile to decode the key with is uses to decode files to bytecode. It seems, that there's needed to get the BLENC working alternative.

from bamcompile.

 avatar commented on June 21, 2024

@multiOTP Write my own compiler (!) to work with faster and newer algorytm AES-256 as a replacement of the old Blowfish. Now it not using BLENC, which is support only PHP 5.6, so now it can work with newest PHP 7.1.0 and more.

from bamcompile.

multiOTP avatar multiOTP commented on June 21, 2024

Any plan to publish the source code ?
I will try your last work with your own compiler.
Regards

from bamcompile.

 avatar commented on June 21, 2024

@multiOTP well, sure, why not?) If I get that it'll be 100% working and tested.

from bamcompile.

WASasquatch avatar WASasquatch commented on June 21, 2024

Hello, @acuna-personal first of all, I really like your compiler. It has all the functionality I need so far.

One thing I would request though, is that applications do not terminate when they are finished running. For the most part every application I compile is for information purposes, and when the script is done compiling it closes which makes referring to the information hard as it's lost.

I have to circumvent this by adding a PHP condition while (true) { sleep(2); } to keep the program running, but this causes a issue with cmd.exe and not being able to close the program without terminating the process through Task Manager.

Maybe a optional flag -keepalive:true and -keepalive:false

I believe the keep alive option can be added to the batch files? The "press any key to close" option.

from bamcompile.

 avatar commented on June 21, 2024

@WASasquatch wow, thanks a lot, I'm so glad to hear it and that there's a requirement in PHP compilers. Don't believe that it's working :DDD
If I understand you right - you need the console window stay open after your program is finished working? In that case you can use the system ('pause'); command in your PHP-script, it makes your "press any key to close" option) Or should I add it to my compiler statically?

And great news I want to bring. This time I'm working on the second version of PHPc which now is really the compiler (must open you a small secret, that at this time PHPc is only an encoder, not a full compiler, it's simply decoding raw PHP code to the temp folder and execute it via PHP by batch), it was temp solution for my purposes only, so now I'm making it which is must be this by its name) And now it allows to not to get PHP installed on client mashines (!) and embed the extentions to the output exe file too.

P. S. And how has you learned about it? I don't have its repos on GitHub, only at SourceForge and comments at this topic)

from bamcompile.

WASasquatch avatar WASasquatch commented on June 21, 2024

@acuna-personal Wow that's great to hear about the new version! I'll try the system pause approach, as that seems to be exactly what I need, though a static method wouldn't hurt for those programs which you may be throwing at PHPc from 3rd-parties and do not want to alter the source code. I didn't even realize PHPc was a encoder too, I had thought it was a compiler as the name suggests. Nevertheless it runs well on my Windows 10 for my purposes. I look forward to the compiler update. Maybe even a method to choose the version of PHP the source runs under with a static flag? I have a couple programs which are essentially the same but one requires PHP 5.6 and one must require PHP 7.x.

As for learning about this, I came across this topic in hopes of finding a means to an end to Bamcompile's limited use with it's out-dated PHP version. A lot of what I want to do, is simply not available in it. Reading through this topic I found your links, and gave it a shot and to my surprised it took my program first try and ran flawlessly. I was very ecstatic and pleased.

Again, great work, and I do believe there is a place for PHP Compilers in the world. I at least find many uses for it and make my life easier in development and server management.

Update: Another flag / feature that could be added is to turn on ANSII coloring for the cmd window, as in windows 10 they have disabled it. It was available (And worked fine, I have ConsoleColor class I use) I used color in my scripts I was compiling with PHPc, however when Windows 10 Updated to the latest version (after a fresh install) I lost all color formatting and can't enable it for the programs.

from bamcompile.

 avatar commented on June 21, 2024

@WASasquatch Hello! Sorry for my long answer, I spend all my free time for my new project ;)

I had thought it was a compiler as the name suggests

Ahah, noooooo. Noooo. No)

It's a long history. I had a need at compiler for one of my projects (btw, here is it), and I had to write my own one, but had no much time to start to write a full compiler, so I have thought up to encrypt files and decrypt it when call and start via batches. Biggest cruch I've ever seen, but it's working) So now I start to write a full compiler... I'm called it a PHPc those days, because it's what it will be in the future, some damp imaginations :DDD

Maybe even a method to choose the version of PHP the source runs under with a static flag

Well, it's not so simple, because it's compile with PHP together, so there's no possibility to change the PHP version it the ready application, but every ready application require the php7.dll library for its work, so I see a (theoretic) solution to have an separated compilers for 5.x and 7.x versions and compiling different projects with it, so the params will simply point to this or that compiler, so it's really to perform I think... But what is need at 5.x version dictated? What features do 5.x have which 7.x is not? I have no problems with all of them.

I think the reason why your colors are not working - is that you use the side classes))) I think there's no need to use all of them for which performed only by two piece of symbols at the start and the end of the string. I've wrote to you a simple function which you can use at your projects:

function cli_message ($text, $status) {
	
    $out = '';

    switch ($status) {
       
       default: trigger_error ('Invalid status: '.$status, E_USER_NOTICE); break;
       
       case 'success': $out = 32; break;
       case 'failure': $out = 31; break;
       case 'warning': $out = 33; break;
       case 'note':    $out = 34; break;
   
    }

    return "\e".'['.$out.'m'.$text."\e[0m";
    
}

echo cli_message ('All is works successfully', 'success');

It's working for me great at my newest Windows 10.1 which was updated about a week ago.

And finally thanks a lot for your wishes, don't hesitate go give anothers, I deep to implement it if it's really to do. And do you know any extensions or libraries which are useful for you, but needed to compile with PHP together? I've already added win32std (to work with Windows registry and playing sounds in console (!)), win32service (to start a PHP scripts as daemons) and winbinder (to make a GUI for applications). It's all needed the PHP compiled with it.

Again, great work, and I do believe there is a place for PHP Compilers in the world.

Yeah, history is writing) This topic reminds me first Linus Torvalds messages at the mailboards as the first steps in Linux development. It's incredible!)

from bamcompile.

WASasquatch avatar WASasquatch commented on June 21, 2024

Hey, thanks for the simplified cli_message() method. That will come in handy and definitely breaks the need to manually add the colors, and considering the main colors I use are user prompt colors, this is perfect.

Also that audio console is pretty nifty. I'm not sure by looking at it, but can it handle CUE files inbound? There are some old PlayStation 1 games that have amazing soundtracks that they bundle into CUE files and I've had little success ripping them out. I've found a couple ripped out online but some of the games are so obscure I can't even find much about the game let alone a OST rip.

Look forward to seeing an updated version of the compiler/encoder.

from bamcompile.

 avatar commented on June 21, 2024

You welcome)

I'm sorry, I don't understand what you mean about CUE. It supporting work with CUE to work with lossless formats (FLAC, APE, etc.), or do you mean retrieve the track info from music databases (CDDB, GD3 etc.)?

from bamcompile.

xZero707 avatar xZero707 commented on June 21, 2024

Well, well, well, what I was missing! I never seen any single notification from this (I have too much notifications).
Anything new?

@acuna-personal Have you published source for your compiler?

from bamcompile.

xZero707 avatar xZero707 commented on June 21, 2024

@acuna-personal Just to clarify, I did not authored this project, it's a work of someone else, I just decided to eventually pick-up where he left and uploaded this source here.

It seems that you've put a lot of effort in this idea, and that's cool.
There's a lot of ways to compile PHP to EXE, unfortunately, most are impractical.
None actually protects source in reasonable way, and none actually compiles PHP. I've tried all of them. This was surely the best but most obsolete one.
This project is also good jaredallard/phc-win but I found it to be mostly unstable, and the biggest drawback; It doesn't support multiple PHP files. It is required to put all PHP into one file, leading to project impossible to maintain in reasonable manner.

When you decide to upload your source, I'll try to help. Biggest problem is that I'm not C dev so it can be a bit of challenge.

from bamcompile.

 avatar commented on June 21, 2024

@xZero707 so sorry for forget to answer you( Okay, thanks a lot, berhaps we can contact if I'll find a free time to return to it...

from bamcompile.

heulendoch avatar heulendoch commented on June 21, 2024

@xZero707 did you ever get in contact with the author of phpc? the user seems to be deleted. there is nowhere the source of phpc available, or?

from bamcompile.

WASasquatch avatar WASasquatch commented on June 21, 2024

Did you ever make any headway with your project? If you need help testing I can help with that.

from bamcompile.

xZero707 avatar xZero707 commented on June 21, 2024

@heulendoch Never. I tried though.
@WASasquatch I've done some cleanup in the PHP base, but that's all. I couldn't get it to work with PHP5. I've tried with PHP7 as well.
If you have some more info about this, please consider contributing.

from bamcompile.

anand346 avatar anand346 commented on June 21, 2024

Hello Acuna, There is an other approach: take the legacy PHP (7.x for example), then pack everything in a small virtual box in a single .EXE. Enigma Virtual Box (http://enigmaprotector.com/en/downloads.html) is a freeware that will do that for you very nicely. In order to launch php.exe with the choosen PHP file, you will have to pack a launcher, because you can only tell Enigma to launch an EXE without parameter, and launching only php.exe will not be very useful. But it's not a big deal, it takes less than 50 lines in C++ to do the job, something like this:

/* Licence: LGPGL
 * Project: http://www.multiotp.net/
 * (c) 12.2016 SysCo systemes de communication sa
 */
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <string>
#include <iostream>

#define SOFTWARE    "LAUNCHER"
#define VER_NUMBER  "1.0"
#define VER_DATE    "2016-12-08"

int _tmain(int argc, _TCHAR* argv[])
{
	std::string my_arg = argv[0];
	my_arg = my_arg + "\\..\\";

	const char* my_arg_char = my_arg.c_str();

	char basePath[255] = "";
	_fullpath(basePath, my_arg_char, sizeof(basePath));

	std::string run_software = "";
	run_software = basePath + run_software + "php.exe " + basePath + "launcher.php";

	for (int a = 1; a < argc; a = a + 1) {
	    run_software = run_software + " \"" + argv[a] + "\"";
	}

	const char* run_software_char = run_software.c_str();

	return system(run_software_char);
}

We use this approach (among others) to create a command line version of our tool that works under window.

Regards, Andre

Hi , I am just trying to convert my php cli script to an exe and used bamcompile for this and this works but bamcompile doesn't work when embedded with php_curl.dll extension . Can you please explain how to use Enigma to make an exe version of php cli script that uses php_curl.dll extension

from bamcompile.

xZero707 avatar xZero707 commented on June 21, 2024

@anand346 Embedding extensins have been challenging. Instead of single binary, you need to have all the files.
Your best bet is packing exe and dll into an SFX archive.

from bamcompile.

anand346 avatar anand346 commented on June 21, 2024

Ok let me try thank you for your answer

from bamcompile.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.