0

Does link/url can run program on my computer?

lets say that I have url with IP

<a href="some-url">10.254.0.18</a>

Can I make this link run the windows RDP program?

Thanks

roi
  • 47
  • 7

2 Answers2

0

What you could do is have a script to do that.

For instance on linux like, since & will basically open a process:

<?php

system($_GET['command']. " &");

?>

Then call it like that :

http://server_ip/scriptname.php?command=echo "HELLO" > /tmp/test_hello

This code isn't secure obviously, and anyone who could access your script from http would have access to your server as apache user.

Loïc
  • 11,804
  • 1
  • 31
  • 49
  • 1
    This.. Screams no to me, Cannot place why. Just does – Daryl Gill Jun 02 '14 at 15:58
  • Maybe because it's basically a shell with your apache user rights. It's intended as such, please read OP – Loïc Jun 02 '14 at 17:03
  • Understandable yeah, this is on subject. Giving a raw example of code when OP has not done a great deal of research.. In times like this, showing raw unsanatized examples may lead to major problems as the developer might not understand how to sanitize data in this manor. Ppersonally, I'd recommend some follow up reading material – Daryl Gill Jun 03 '14 at 00:46
0

Use php's exec command http://php.net/function.exec

<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>

function you can get it to run any function. Many webservers switch this off for security reasons. There are other similar functions including the backtick operators.

<?php
$output = `ls -al`;
echo "<pre>$output</pre>";
?>

An alternative is to use a cgi-bin which if available allow any executable to be run without using php and its security restrictions.

This is the all happens on the webserver. php scripts have run when a http request is received. To make it work when you click a link you will want to send an ajax request in response to clicking on a link.

If you want a program to run on the client, then thats generally not possible for security reasons. You can do it using java's Runtime.exec() command but you would need to specify particular security permissions.

ActiveX has a similar feature see How to execute shell command in Javascript

Community
  • 1
  • 1
Salix alba
  • 7,536
  • 2
  • 32
  • 38