我正在开发C#中的Internet Explorer浏览器帮助对象(BHO)。此BHO检测用户导航到的URL,然后自动填充用户名和密码。C#:降低命名管道的完整性
BHO与作为服务运行的进程进行通信。通信发生在命名管道上。
当保护模式关闭时,通信正常工作。但是,当保护模式打开时,这不起作用。如果我运行iexplore.exe作为管理员,那么它的作品。
在保护模式下,我得到访问被拒绝的消息。
阅读了解后,我意识到管道访问被拒绝,因为IE在 上运行的是低完整性范围。
我已经通过了以下文章 a。了解并在保护模式下工作Internet Explorer http://msdn.microsoft.com/en-us/library/bb250462.aspx
b。在创建管道资源之前,还经历了许多关于设置安全信息的建议,以允许较低的完整性进程使用此信息。但这些对我来说没有多大用处。 我仍然得到相同的错误。
我目前唯一的工作就是通过套接字进行通信。我证实了这种方法的效果。
我宁愿使用命名管道方法。
以下是打开管道
服务端代码之前设置的安全上下文我的源代码:
PipeSecurity security = new PipeSecurity();
security.AddAccessRule(new PipeAccessRule(
new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), // @"Users"
PipeAccessRights.ReadWrite,
System.Security.AccessControl.AccessControlType.Allow
));
var currentUser = WindowsIdentity.GetCurrent().Name;
security.AddAccessRule(new PipeAccessRule(currentUser, PipeAccessRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
NamedPipeServerStream stream;
stream = new NamedPipeServerStream(
CommandPipeName,
PipeDirection.InOut, MAX_PIPE_INSTANCE,
PipeTransmissionMode.Message, PipeOptions.WriteThrough,
EPHelperCommandPipeServerConsts.MaxPipeRequestLength,
EPHelperCommandPipeServerConsts.MaxPipeResponseLength,
security
);
do
{
n++;
isListening = true;
stream.WaitForConnection();
isListening = false;
var cs = stream;
stream = new NamedPipeServerStream(
CommandPipeName,
PipeDirection.InOut, MAX_PIPE_INSTANCE,
PipeTransmissionMode.Message, PipeOptions.WriteThrough,
EPHelperCommandPipeServerConsts.MaxPipeRequestLength,
EPHelperCommandPipeServerConsts.MaxPipeResponseLength,
security
);
// some code
} while (true);
有没有办法,我失去了一些东西?
谢谢。
保护模式值不一定意味着:“使用命名管道在与管理员权限运行的服务运行代码的所有代码都应该停止,除非矿”。 没有“除我的”条款。当然每个人都会认为这适用于他们,使得该功能无用。这应该是显而易见的。 –
为什么将当前用户添加到PipeAccessRule?作为管道的第一个拥有者,默认情况下,创建者已经完全控制。 –
感谢Hans,我不明白你的意见。你能否详细说明你的评论? AFAIK我不假设。 –