如何从进程内存中删除字符串? [英] How to remove string from process memory?

查看:110
本文介绍了如何从进程内存中删除字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,该应用程序从Windows窗体文本框中获取字符串,并将其传递给使用字符串作为参数的API.我看到任务完成后,仍然可以从进程内存中查询字符串.我遇到了使用SecureString进行字符串内存管理功能的建议.但是,如果我理解正确的话,如果安全字符串是根据字符串构建的,或者最终将安全字符串的值存储在字符串中,那么字符串的目的就无法实现.

I have an application which takes a string from the Windows Forms text box and passes it to an API which uses a string as the parameter. I see that the string can still be queried from the process memory after the task is complete. I have come across suggestions to use SecureString for string memory management capabilities. But, if I understand correctly, the purpose of the string is defeated if the secure string is built from a string or the value of the secure string is ultimately stored in a string.

请提出最佳解决方案.

Please suggest what is the best possible solution.

推荐答案

SecureString被认为不安全.如果需要这样做,可以使用char[]并在完成后覆盖数据,也可以在完成后使用unsafe代码覆盖string(只是...希望它不是实习生或共享参考文献;请注意,这适用于调用堆栈中的无处不在.请注意,操作系统可能出于各种原因复制了该页面,并且如果不是非常仔细地分配内存,甚至可能在磁盘(交换文件)上.

SecureString is not considered secure. If you need to do this, you can either use a char[] and overwrite the data once done, or you can use unsafe code to overwrite a string when done (just... hope it wasn't interned or a shared reference); note that this applies everywhere in the call stack. Note that the OS may have copied the page for various reasons and it may even be on disk (swap file) if the memory wasn't very carefully allocated.

但是,当内存分析工具成为winforms应用程序中的一个因素时,使用按键记录器,或者只是用扳手威胁别人输入密码会更容易:

However, by the time memory analysis tools are a factor in a winforms app, it would be easier to use a key logger, or just take a wrench and threaten someone for the password:

这篇关于如何从进程内存中删除字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆