简体   繁体   English

查看传递给程序的命令行参数

[英]See command line arguments being passed to a program

You may skip this part你可以跳过这部分

I am using a batch file that I have in my thumb drive in order to mount a true crypt volume.我正在使用我的拇指驱动器中的批处理文件来安装真正的 crypt 卷。 I created that batch file with the help of this link .我在此链接的帮助下创建了该批处理文件。 on that batch file I have the username and password that I pass as arguments to trueCrypt.exe in order for it to be mounted.在该批处理文件中,我将用户名和密码作为参数传递给 trueCrypt.exe,以便安装它。


Anyways so my question is: will it be possible to see the arguments being passed to a program from a third party process?无论如何,我的问题是:是否有可能看到从第三方进程传递给程序的参数? In other words, will it be possible to see the arguments being passed to this program:换句话说,是否可以看到传递给该程序的参数:

using System;
using System.Reflection;
using System.Diagnostics;

class Program
{
    static string password = "";

    static void Main(string[] args)
    {
        if (args.Length > 0)
            password = args[0];

        // get location where this program resides 
        var locationOfThisExe = Assembly.GetExecutingAssembly().Location;


        Console.Write("Press enter to start a new instance of this program.");
        Console.Read();

        var randomArgument = new Random().NextDouble().ToString();
        Process.Start(locationOfThisExe, randomArgument); 
        // I am passing a random argument to a new process!
        // is it possible to see these arguments from another process?
    }
}

Edit编辑

I am creating an edit cause I think I explained my self incorrectly but this edit should be a solution instead of a question我正在创建一个编辑,因为我认为我错误地解释了我自己,但这个编辑应该是一个解决方案而不是一个问题

I think this question has not received enough attention.我认为这个问题没有得到足够的重视。 Executing the command showed by https://stackoverflow.com/users/235660/alois-kraus shows:执行https://stackoverflow.com/users/235660/alois-kraus显示的命令显示:

(I pasted the output on notepad++) (我在记事本++上粘贴了输出)

在此处输入图片说明

on the image it does not show very clearly but I was able to see the argument being pass to that process.在图像上它没有显示得很清楚,但我能够看到传递给该过程的参数。 That matters a lot to me because I mount my true crypt volumes with the command:这对我来说很重要,因为我使用以下命令安装了真正的 crypt 卷:

"C:\\Program Files\\TrueCrypt\\TrueCrypt.exe" /v "a:\\volume.tc" /lz /a /pa "C:\\Program Files\\TrueCrypt\\TrueCrypt.exe" /v "a:\\volume.tc" /lz /a /pa

that tells to truecrypt that I want to mount the volume located at a:\\volume.tc on drive letter z and the password is a它告诉给TrueCrypt的,我想挂载位于体积a:\\volume.tc驱动器字母Z,密码是a

If I execute that command true crypt will mount that volume on drive z:如果我执行该命令 true crypt 将在驱动器 z 上安装该卷:

在此处输入图片说明

the problem is that If I then execute the command wmic process note what shoes up:问题是,如果我然后执行命令wmic process注意什么鞋子:

在此处输入图片说明

Note the password is in there!注意密码在里面!

So in summary it is not safe to pass secure information as an argument.所以总而言之,将安全信息作为参数传递是不安全的。 It may be secure if you close the process that received the arguments but I think it is important to be aware of this...如果您关闭接收参数的进程可能是安全的,但我认为意识到这一点很重要......

If other users with administrative rights or with the same user account can execute programs you can see all command lines with如果其他具有管理权限或具有相同用户帐户的用户可以执行程序,您可以看到所有命令行

wmic process

from all processes with this single command line.从所有进程使用这个单一的命令行。

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

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