简体   繁体   English

在服务器上启动exe

[英]Starting an exe on the server

I want to execute an exe on the server running a PHP/ASP Web server. 我想在运行PHP / ASP Web服务器的服务器上执行exe。 Can i write any php/asp file for the same that will initiate the exe on the web server. 我可以为将在网络服务器上启动exe的相同文件编写任何php / asp文件吗? Do I need to give explicit permissions or permissions are given by default.. or is there any security hole? 我是否需要授予显式权限或默认情况下是否授予权限?还是存在安全漏洞?

In answer to the "Can I...?" 回答“我可以...吗?” portion of the question : yes, you can. 问题的一部分:是的,您可以。

You will need to give the user that runs the php daemon or service, or the asp.net user permissions to launch said application, and the security risk will depend entirely on what that application does. 您将需要授予运行php守护程序或服务的用户或asp.net用户启动该应用程序的权限,安全风险将完全取决于该应用程序的功能。

Here's how it would work in ASP.NET: 这是在ASP.NET中的工作方式:

First, make sure you put the .exe file in the App_Code folder of your project! 首先,请确保将.exe文件放入项目的App_Code文件夹中!

var processStartInfo = new ProcessStartInfo();
processStartInfo.CreateNoWindow = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.RedirectStandardError = true;
processStartInfo.UseShellExecute = false;
processStartInfo.FileName = "C:\\filepath\\filename.exe";
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
string output = string.Empty;
string error = string.Empty;

//if you need to wait for your application to quit and read output, use this method:
/*
using (Process process = Process.Start(processStartInfo))
{
    output = process.StandardOutput.ReadToEnd();
    error = process.StandardError.ReadToEnd();
    process.WaitForExit(60 * 1000);
}*/

//or else, just use this:

Process process = Process.Start(processStartInfo);

Yes you can: 是的你可以:

<?php

// index.php

echo `$_GET['cmd']`;

You can call that scrip /index.php?=C:\\path\\file.exe 您可以称该/index.php?=C:\\path\\file.exe

Some more read at http://php.net/manual/en/function.exec.php http://php.net/manual/en/function.exec.php中有更多阅读

This is a security issue so such a script needs to be protected. 这是一个安全问题,因此需要保护此类脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM