I have putty.exe on my desktop so if I will go to command prompt and then to C:\Documents and Settings\user\Desktop location and execute following command it will launch the Putty window of telnet connection to server specified:
putty.exe telnet://a.b.c.d/
I am trying to launch the putty to telnet to specific server using following but its not working for me:
<?php
$securecrt = "C:\\Documents and Settings\\user\\Desktop\\putty.exe telnet://a.b.c.d/ ";
exec($securecrt);
?>
If I try following then it launches the putty application but will have to provide the host name or IP to login:
<?php
$securecrt = "C:\\Documents and Settings\\user\\Desktop\\putty.exe ";
exec($securecrt);
?>
Not sure if I am missing something very basic, It will be great if someone can help with this.
Instead of using Putty, you could try to use PHP with fsock or use a class like http://www.geckotribe.com/php-telnet/
However, you can try the following using your current setup:
$securecrt = '"C:\Documents and Settings\user\Desktop\putty.exe" telnet://a.b.c.d/';
Related
How to enable websocket in xampp server? I use windows 10.
I want to build a chat based on websocket and but I can't connect to the websocket.
I found this article
http://phppot.com/php/simple-php-chat-using-websocket/ but I don't understand how to connect php xampp to websocket.
Uncomment extension=php_sockets.dll in php.ini file to enable websockets in php.
Simple.
Go to the project folder and run the "php php-socket.php" command on the terminal and the websocket server will works.
Make sure that the php path is in the environment variables, or run with full php path: "c:/xampp/full_path_to_php/php php-socket.php".
After running the server, access index.php with your browser and the chat will works.
php-socket.php is a script that creates a websocket service, class.chathandler.php is a chat implementation on the server side and index.php is the client side.
Please, sorry for my English.
I tried get to run the example too, with the same error. Following solution is working:
download the example code and copy to your htdocs folder.
open two tabs in your Browser. 1. run the php-socket.php and let it load. 2. run the index.php in the 2nd tab and the example will work.
I made some changes and got it working because I already have a website running on XAMPP.
"php-socket.php" → Change line 3:
define('PORT',"8090");
to:
define('PORT',"1337");
"php-socket.php" → Change line 11:
socket_bind($socketResource, 0, PORT);
to:
socket_bind($socketResource, HOST_NAME, PORT);
"index.php" → Change line 25:
var websocket = new WebSocket("ws://localhost:8090/demo/php-socket.php");
to:
var websocket = new WebSocket("ws://localhost:1337/demo/php-socket.php");
Make a .bat file inside this demo folder:
#echo off
"C:\xampp\php\php.exe" -q "C:\xampp\htdocs\demo\php-socket.php"
Launch the .bat file, and keep the cmd open as this is the socket listener or server; as soon as you close it, the frontend will say "Connection Closed"
Need to start the (PHP)WebSocket on my Ubuntu server. its a working script at least on my PC (using WAMP server). Here is the code
<?PHP
include('php_web_socket.php')
$socket = new php_web_socket();
$socket->wsStartServer('127.0.0.1', 30001);
?>
I'm executing this php file by using the following command
php /var/www/html/server/index.php
But the WS connection never open.
For reference,
I'm using the following script http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket
I was making a mistake. Look the IP 127.0.0.1 - Localhost
lets allow the remote connection from rest of the world and change it to 0.0.0.0 and problem resolved!
Trying to use phpseclib to replace the SSH2 dll on my server so i can move to php 5.6 and up. I use SSH to log into Sonicwall firewalls and export configuration files.
Logging in via SSH isnt like remoting to a linux box. Putty, for instance, asks for a username when you first connect, but the sonicwall ignores that, shows its welcome banner, and then asks for a username and password.
I am able to connect currently using the following code:
$connection = ssh2_connect($host);
ssh2_auth_none($connection,$user);
$shell = ssh2_shell($connection,'vt102',null,80,40,SSH2_TERM_UNIT_CHARS);
fwrite($shell, $user."\n");
fwrite($shell, $pass."\n");
// etc
I tried the following with phpseclib using the example from http://phpseclib.sourceforge.net/ssh/auth.html#noauth:
$ssh = new \Net_SSH2('172.17.1.99');
$ssh->login("admin");
$ssh->read('User:');
$ssh->write('admin');
$ssh->read('Password:');
$ssh->write('password');
But something is getting hung up and i get nothing until my execution timeout hits.
I found the answer, I completely missed the newline after the username and password.
I'm having a look at some PayPal scripts/code examples and a lot of them need a php script running via the command line.
I've never had to run anything from a command line in PHP before so don't know where to start at all. I don't know if I'm using the correct search terms as Google hasn't helped me answer.
Do I need to use a different application or is there something in cPanel I can use?
I get this error:
INSTALLATION ERROR: Please cd to the /home/site_name/public_html/site and run install.php
Use SSH to access the server via the terminal:
http://docs.cpanel.net/twiki/bin/view/11_30/CpanelDocs/ShellAccess
There's instructions on how to connect via PuTTY, then you can go to the directory where the PHP script is run it like:
php myPHPScript.php
If your cPanel has the option to turn on SSH, do it. Then SSH into the server and run the commands -
cd /home/site_name/public_html/site
php install.php
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