Windows 命令行历史记录

发布于 2024-08-23 01:05:42 字数 253 浏览 7 评论 0 原文

我需要使用 C 以编程方式在 Windows 中安装 WebDAV 卷,并且我想我将使用 system() 来实现此目的(通过“net use”命令)...但是,由于 net use 要求密码为用纯文本编写,我只是想确保没有记录在 Windows 命令行 shell 中运行的命令...我知道在 Mac OS X 和 Linux 中,在某些情况下命令可以记录在文件 .bash_history 中,所以我想也许 Windows 中也发生了类似的事情。但我不这么认为,因为谷歌上什么也没有出现。

I need to programmatically mount a WebDAV volume in Windows using C, and I think I'm going to use system() to achieve this (via the 'net use' command)... However, since net use requires that the password be written in plain text, I just wanted to make sure there's no logging of commands run in the Windows command line shell... I know in Mac OS X and Linux in some circumstances commands can be logged in the file .bash_history, so I thought maybe something similar was going on in Windows. I don't think so though, since nothing showed up on Google.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

北笙凉宸 2024-08-30 01:05:43

shell 有历史记录,但它仅存储在内存中,而不是磁盘上的日志。也就是说,它最终可能会出现在交换文件中并可供(稍微不平凡的)发现。话又说回来,如果您使用 WNetAddConnection2 之类的东西直接在自己的程序中进行连接,那么它最终可能会出现在交换文件中。

The shell has a history, but it's only stored in memory not a log on disk. That said, it could end up in the swap file and open to (slightly non-trivial) discovery. Then again, if you did the connection directly in your own program using something like WNetAddConnection2, it could end up in the swap file anyway.

苏辞 2024-08-30 01:05:43

使用 'CreateProcess 可能会更好' 并将输入和输出重定向到您的代码,并通过写入 stdin (这将被重定向到“Net use”命令)将其输入到代码中,并读取输出,这样,密码输入就不会被记录...这是理论上的...如果 popen 实现存在...因为它符合 POSIX 标准并且在标准 C 中找不到...它存在于 *nix 世界中...

编辑:好消息,我发现了一些模拟 popen 使用 CreateProcess 的包装器,只是认为它可能有帮助。代码需要稍微调整一下...它是 GPL v2 许可证..所以..需要记住一些事情...

希望这会有所帮助,
此致,
汤姆.

It might be better to use the 'CreateProcess' and redirect the input and output to your code, and feed it into it by writing to stdin (which would be redirected to the 'Net use' command), and read the output, in that way, the password input would not be logged... this is in theory....I am not 100% confident if the popen implementation exists....as it's POSIX compliant and not found in standard C...it exists in the *nix world...

Edit: Good news, I found some code that emulates a popen using a wrapper around CreateProcess, just thought it might help. The code would need to be tweaked a bit...It's GPL v2 licence..so..something to bear in mind...

Hope this helps,
Best regards,
Tom.

旧故 2024-08-30 01:05:43

不是您问题的答案,而是检查 net use rel="nofollow noreferrer">WNetAddConnection2 win32函数

Not an answer to your question, but instead of net use check WNetAddConnection2 win32 function

紫瑟鸿黎 2024-08-30 01:05:43

Windows 命令 shell 没有任何内置命令日志记录,它使用外部命令(doskey),我不认为来自 system() 命令的命令提示符已安装 doskey ,但如果您想确定,请使用 system() 执行

doskey /history

,它将输出该命令提示符实例的命令行历史记录。

The windows command shell doesn't have any built in command logging, it uses an external command for that (doskey), I don't think that a command prompt from a system() command has doskey installed, but if you want to be certain, use system() to execute

doskey /history

and it will output the command line history for that instance of the command prompt.

汐鸠 2024-08-30 01:05:43

普通的命令界面没有历史记录,除非你明确激活它(但我不记得这个命令可用,我上次检查是在 DOS/Windows 中 95 天)。 Visual Studio 命令提示符确实有历史记录——但我怀疑当您关闭提示符时它是否会保留。

A normal command interface doesn't have a history unless you explicitly active it (but I can't remember this command being available , last I checked was in the DOS/windows 95 days). Visual studio command prompt does have a history though -- but I doubt its retained when you close the prompt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文