level 8
贴吧用户_Q4NE46W
楼主
各种拒绝访问。
我要改的权限也就是右键注册表项,权限里面
俗称安全选项卡
跟文件的安全选项卡类似
我就是要用vb.net改注册表项HKLM\SAM\SAM的权限 完全控制
我的代码:
Sub Main()
Console.ForegroundColor = ConsoleColor.DarkCyan
Console.WriteLine()
Dim CrtWP As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(Security.Principal.WindowsIdentity.GetCurrent)
If CrtWP.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator) Then
Console.WriteLine("[+][Administrator]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
ElseIf CrtWP.IsInRole(Security.Principal.WindowsBuiltInRole.User) Then
Console.WriteLine("[+][User]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
Else
Console.WriteLine("[+][Unknown]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
End If
Console.ForegroundColor = ConsoleColor.DarkGreen
Console.WriteLine()
Try
Using RegKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SAM")
Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl()
Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Security.Principal.WindowsIdentity.GetCurrent.User, RegistryRights.FullControl, AccessControlType.Allow)
RegkeyAcl.AddAccessRule(AccessRule)
RegKey.SetAccessControl(RegkeyAcl)
End Using
Console.WriteLine("[+]应用注册表权限成功!")
Catch ex As Exception
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("[-]设置注册表权限时发生错误:" & ex.Message)
End Try
Console.ReadKey()
End Sub
运行效果:

出错代码这一行:

设置其他注册表项权限都很顺利,没有这么多问题,就是这个HKLM\SAM\SAM比较特殊啊,失败的原因肯定不是权限问题,在注册表编辑器里是可以改的,但我的程序各种问题,求吧里大牛帮忙看一下。。不要问我改SAM权限干什么用
2015年11月07日 10点11分
1
我要改的权限也就是右键注册表项,权限里面
俗称安全选项卡
跟文件的安全选项卡类似
我就是要用vb.net改注册表项HKLM\SAM\SAM的权限 完全控制
我的代码:
Sub Main()
Console.ForegroundColor = ConsoleColor.DarkCyan
Console.WriteLine()
Dim CrtWP As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(Security.Principal.WindowsIdentity.GetCurrent)
If CrtWP.IsInRole(Security.Principal.WindowsBuiltInRole.Administrator) Then
Console.WriteLine("[+][Administrator]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
ElseIf CrtWP.IsInRole(Security.Principal.WindowsBuiltInRole.User) Then
Console.WriteLine("[+][User]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
Else
Console.WriteLine("[+][Unknown]当前登录Windows账户:" & Security.Principal.WindowsIdentity.GetCurrent.Name)
End If
Console.ForegroundColor = ConsoleColor.DarkGreen
Console.WriteLine()
Try
Using RegKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SAM")
Dim RegkeyAcl As RegistrySecurity = RegKey.GetAccessControl()
Dim AccessRule As RegistryAccessRule = New RegistryAccessRule(Security.Principal.WindowsIdentity.GetCurrent.User, RegistryRights.FullControl, AccessControlType.Allow)
RegkeyAcl.AddAccessRule(AccessRule)
RegKey.SetAccessControl(RegkeyAcl)
End Using
Console.WriteLine("[+]应用注册表权限成功!")
Catch ex As Exception
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("[-]设置注册表权限时发生错误:" & ex.Message)
End Try
Console.ReadKey()
End Sub
运行效果:

出错代码这一行:
设置其他注册表项权限都很顺利,没有这么多问题,就是这个HKLM\SAM\SAM比较特殊啊,失败的原因肯定不是权限问题,在注册表编辑器里是可以改的,但我的程序各种问题,求吧里大牛帮忙看一下。。不要问我改SAM权限干什么用
