Run a program from an array of bytes without creating a temporary file . c#

后端 未结 3 1810
眼角桃花
眼角桃花 2021-01-25 04:47

I have many .exe files stored on IIS server (MSSQL) that contain reports and access to the file(s) on the servers . (These files will be change on Sundays .)

After conne

3条回答
  •  醉话见心
    2021-01-25 05:02

    There are two different concerns for security here:

    1. That someone can see the file that you've downloaded from the database.
    2. That executing the file might be a security threat.

    For the first concern: Create a directory on the server and restrict access to that directory so that no one but the user account that runs your server program can see/use it. Save the byte array into a temporary file in that directory, execute it, and once the process has completed, delete the temporary file.

    For the second concern: You'll need to run that executable in a sandboxed environment. In .NET you can run code in a sandboxed environment by loading the code into a separate AppDomain that you've setup to only have partial trust. How to do that deserves another question on SO though.

提交回复
热议问题