Extracting self-extracting exe archive via php
I have a problem. I have the service which is giving me .exe file which they claim is in fact zip archive. A self-extracting archive. Problem is that I am downloading that with my app (php) to server and need to extract it there witout downloading to local computer. I have tried download .exe file to local computer - it is self extracting on windows to /temp dir and than self launching FLASH player.
$zip = zip_open($myfile); gives in print_r($zip): 1 zip->open gives no results either. change .exe to .zip doesn't let win开发者_JAVA技巧zip or other kind of un-packer on windows to open it - .exe cannot be opened by winzip too.
Now I have no idea how to deal with it. If anybody can advise please.
Try to execute the program as an executable with the system command
Executing files from an external source you don't trust 100% is never a good idea.
The info-zip version of zip allows you to remove the SFX stub from a self-extracting zip file (with the -J flag) converting it back into a normal zip file.
Source code is freely available.
Making a self-extracting zip file is a matter of prepending a zip file with the SFX binary code, then appending the size of the binary stub to the resulting file - but I'm not sure how the data is represented - but a bit of reverse-engineering the available code should make this clear.
Well... if your PHP server is Windows you shouldn't have a problem doing it as a system command. Otherwise, it's a little more tricky. I hear that the unzip system command will unzip self-extracting zip files, but I don't have access to a Linux box at the moment to try it out.
If you're on shared hosting, chances are you can't do it.
Well if you think after executing the exe file, it will extract its content, then you can use exec
function to run the .exe files like the one below:
exec("d:\\example\\php\_exe\\1436.exe");
and also you can use system
function to run external programs as well.
And also if you wonder what's the difference:
PHP - exec() vs system() vs passthru()
精彩评论