简体   繁体   English

隐藏命令行参数

[英]Hiding Command line arguments

I am invoking an exe to do certain operation on a device, Exe needs password to connect to device to perform the operation. 我正在调用exe来对设备进行某些操作,Exe需要密码才能连接到设备来执行操作。

Problem : password is visible in task manager under command line column. 问题:密码在命令行列下的任务管理器中可见。

I tried deleting command line argument detail from PROCESS_BASIC_INFORMATION by following command : 我尝试通过以下命令从PROCESS_BASIC_INFORMATION中删除命令行参数详细信息:

HANDLE hProcess = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
                               FALSE, GetCurrentProcessId());
PROCESS_BASIC_INFORMATION pbi;
ULONG ReturnLength;
PFN_NT_QUERY_INFORMATION_PROCESS pfnNtQueryInformationProcess =
    (PFN_NT_QUERY_INFORMATION_PROCESS) GetProcAddress (
        GetModuleHandle(TEXT("ntdll.dll")), "NtQueryInformationProcess");
NTSTATUS status = pfnNtQueryInformationProcess (
    hProcess, ProcessBasicInformation,
    (PVOID)&pbi, sizeof(pbi), &ReturnLength);
// remove full information about my command line
pbi.PebBaseAddress->ProcessParameters->CommandLine.Buffer = NULL;
pbi.PebBaseAddress->ProcessParameters->CommandLine.Length = 0;

But command line information still appears in task manager. 但命令行信息仍会出现在任务管理器中。

Could you guys help me to understand how task manager is reading command line argument and how it can be changed? 你能帮助我理解任务管理器如何阅读命令行参数以及如何更改它?

Thanks, Pooja 谢谢,Pooja

Not sure if this helps but I had to write an app that interfaces with SQL via command line and needed to hide our Database password, while it is not 100% it does work for what I need. 不确定这是否有帮助但我必须编写一个通过命令行与SQL接口并且需要隐藏我们的数据库密码的应用程序,而它不是100%它确实适用于我需要的东西。 In the command line arguments, I start the arguments with 465 spaces; 在命令行参数中,我用465个空格开始参数; It was a random number I tried when I first came up with the idea, the command line does not care about space and has a high character limit; 当我第一次想出这个想法时,这是一个随机数,命令行不关心空间并且字符限制很高; the task manager on the other hand does not have a high character limit so all it displays it the exe and a bunch of whitespace and that is it. 另一方面,任务管理器没有高字符限制,所以它只显示exe和一堆空格,就是这样。

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

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