I have installed .exe file using wine in my linux machine. Using shell_exec I could launch the exe file via command prompt using php. When I try to run php program from the browser am getting a blank page. How to launch the executables from the browser using php?
And also, using ip address I should be able to launch in other system browser which is installed in one system.
php code:
<?php
shell_exec("cd / ; wine /home/quads/.wine/drive_c/Program\ Files/MathType/MathType.exe");
?>
If I run this through command prompt it could launch an application but via browser it
doesn't work.It it works via browser then I can access that application from other system using
myipaddress/phpprogram
Please try this
<?php
shell_exec("wine MathType");
?>
It will work only in Internet Explorer and ActiveX control should be enabled in the browser
code:
function openapp(){
var obj=new ActiveXObject("WScript.Shell");
obj.Run("file_exe_path",1,true);
}
<input type="button" onclick="openapp();" />
Related
There is apache server installed on my localhost computer (win7 system) with php. c:\apache is my localhost directory. I can connect to localhost with my mobile phone. I can reach the content of the localhost folder and run PHP files.
I want to send a popup message to localhost computer screen via mobile phone connection.
I tried to use a vbs script in php file and tried the following functions :
vbs file content
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Quit (WshShell.Popup( "My message here" ,10 ,"Warning", 64+4096))
exec("message.vbs");
shell_exec("message.vbs")
system("message.vbs)
exec("start message.vbs")
exec("start warning.wav") // It can be a sound message instead of text msg
VBS script works when I run it directly on the local computer but I can't run it from PHP file.
I hope it is clear enough.
Did you tried this?
exec('cmd %pathToVBSFile%');
I found this on php.net:
start MSPaint maximized and wait for you to close it before continuing the script:
<?php
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("mspaint.exe", 3, true);
?>
Did you tried to execute something else than VBS from PHP?
You can try to convert the vbScript to a .exe with Vbs to Exe (maybe apache doesn't have the right to execute VBS)
I want to send a popup message to localhost computer screen via mobile phone connection.
Win 7-8's msg.exe don't display popup message. I did it with windows XP msg.exe. I carried xp's msg.exe to win 7-8's system32 folder. It worked.
I added the following code to my php file test.php. And when I run it from mobile phone, it sends a popup message on localhost computer screen.
http://192.168.1.102/test.php
<? msg username hello world ?>
I have installed WAMP server 2.0 with (PHP 5.4.3). After installing WAMP I have restarted all the services and can open
phpinfo() - it is showing up fine
phpmyadmin - it is also showing up fine.. i can play with database..
however when run simple php file in chrome I could see the code rather than result. below is the code i am trying..
<?php
echo "hello world";
?>
below is the link to file which I am trying to access via chrome.
file:///C:/WAMP/www/hello%20world.php
Make sure you have started apache
Try http://localhost/hello_horld.php
To run this script, start a browser use URL http://localhost/your_file.php or http://127.0.0.1/your_file.php
PHP is a server-side technology (instead of client-side technology like JavaScript). The PHP statements <?php ... ?> are processed in the server, and the results returned to the client (browser). so you need to use it through server not direct
I have an executable file developed using opencv library in cpp and c also. I want to execute it from my website hosted on localhost using a php script.
The problem i'm facing is that, the executable code opens a window(kind of gui, opened using namedWindow) when called from terminal but it doesn't do that when called from the embedded php script.
For execution i have tried exec, system but all these failed.
to be more clear : name of executable -> my_cv_gui, name of phpscript(page) ->abcd.php
#terminal if i type "./my_cv_gui" ... window opens.
# terminal, if itype "php abcd.php" window opens
abcd.php is part of my website. In web browser if i open "http://...../abcd.php", window DOESNOT open. Although other things in the executable work perfectly.
My system configuration
OS : ubuntu 12.04 x64
XAMPP for Linux 1.7.7
Apache 2.2.21
PHP 5.3.8
Opencv 2.4.1
Any solutions??
The php code is as follows
<?php
$output=shell_exec("gst-launch v4l2src device=/dev/video0 ! 'video/x- raw-yuv,width=640,height=480,framerate=30/1' ! ffenc_flv ! flvmux streamable=true ! queue ! filesink location=/home/dev/my.avi > /dev/null &");
var_dump($output);
?>
Two things you should always remember when you are working with apache.
File/Folder Permission. Using which the apache is running.
MIME type should be added to apache to run any kind of multimedia components. Like here it's flv. Then try running the php code and try fixing it. I will check in my server if that works for me. Will update you.
Biswadip.
I have been trying unsuccessfully so far to write a php script that will run when a page is opened and that will launch metasploit!
I ve tried shell_exec and exec and all the other alternatives but although I can get it to do simple things (i.e. ls, cds etc) if I try msfconsole it doesnt do anything!
I have also tried a different script that launches firefox and again nothing happens!
Now i know that php runs on the server and I m not expecting to see a console or firefox opening in the clients machine! Instead in order to check if it works I am trying to echo out the output of the shell_exec!But anyway since im hosting the files on my machine (i.e. this is the server and a VM is the client) if it could actually launch firefox i should be able to see the app opening here in the same way as by just doing this from the command line!
What am I missing?
Is there any other way to do this?(i.e. Launch metasploit everytime a user opens up my page)
NOTE: I've tried specifying the full path for msfconsole but that didnt work either!
Heres what I have so far:
$output = shell_exec('/opt/local/libexec/metasploit3/msfconsole;show');
echo "<pre>$output</pre>";
The ";show" bit was used in order to actually make it run something and print some stuff but didnt make any difference!
When you run a gui application from the command prompt in a X window system, it will use the default display. When you run it using php which is embedded in apache webserver, the program may not know where to display the gui application.
there are 2 things to make this work.
The program that executes the gui application must have permission to use display
you need to tell the program which display to use.
I used the following in my php script
<?php
$cmd = `export DISPLAY=:0; gedit`;
shell_exec($cmd);
?>
and ran the script from terminal using php -f test.php
I got the gedit up and running.
You can test the same with the script in apache too.
Please add apache user with privileges to access display server
update: I just added the following in /etc/apache2/apache2.conf (I am using ubuntu)
User poomalai
Group poomalai
and restarted the web server
sudo service apache2 restart
now I accessed localhost/test.php
and Presto!! I got the gedit :)
Hope this helps
I have written a php script that will enable me to run a few batch files and python script in cmd prompt. The batch files and the python script are located in the same machine as my php script. The php script have a hyperlink image where if a user click the image it will load the command prompt to run the batch files and the python. In order to do this i need to have a .dll file called launchinIE.dll and also enable the activeX settings in the Internet explorer (you can refer to this link http://www.whirlywiryweb.com/q/%2Flaunchinie.asp)
the problem is that the php script can only run properly in internet explorer but not in firefox....... how to do this????
<script language="JavaScript">
function openPyt(strDoc)
{
var obj = new ActiveXObject("LaunchinIE.Launch");
obj.ShellExecute("open", strDoc);
}
</script>
You're using ActiveX, which firefox does not support. It sounds like you're trying to run a python script via a web browser? The simplest way to do this in a way that will work with all browsers is CGI. This means that the code will run on the web server instead of in the web browser, though, which might not be what you want. What are you trying to do?