|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
![]() |
#1 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
How to find out - who is the owner of any registry key?
How to find out about permissions (access rights) in NSIS, who is the owner of any registry key ?
How can you use the RegGetKeySecurity function for these purposes ? ps AccessControl plug-in - why doesn't it work ... code: |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
There was a bug, I uploaded a new version.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Thank you Anders !
Is it possible to add another very important option: who has full control over the registry key ? For example: AccessControl::GetRegKeyFullControl FullControl : builtin \ Administrators , SYSTEM FullControl : TrustedInstaller |
![]() |
![]() |
![]() |
#4 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
I don't see how that is useful. You can be pretty close to FullControl without actually having it. For the registry, somebody could have everything except notify right for example, this is effectively the same as FullControl. Anyone with with WRITE_DAC can give themselves FullControl if they want it.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#5 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Knowing who has full control is important for using reg files. (This is even more important than knowing who the owner of the registry key is).
If system or TI has full control, then you have to use special utilities, such as Subinacl, etc. This is important to know in advance. For example, in PowerShell there is a GetAcl command. Unfortunately, NSIS does not yet have such a toolkit... |
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
That is simply not how ACLs work. System or TI are not special, they don't block access to others simply by existing in the ACL.
Newer versions of Windows try to make it harder for people to write to certain keys. This forces people to first take ownership of the key so that they can add write access for themselves. IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#7 | |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Quote:
It would be nice with the AccessControl plug-in... |
|
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
It already has SetRegKeyOwner
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#9 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
|
![]() |
![]() |
![]() |
#10 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
Because?
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#11 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Because, for example, in Windows 10, in my scripts I often have to run different reg files to change the system settings. And very often, these reg files must be run with elevated rights, which is not known in advance. You need to know who has full control over a given registry key.
Do not go into the registry every time to manually view the rights ... |
![]() |
![]() |
![]() |
#12 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
Which keys are not working?
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#13 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
There are many keys that are not available to the user due to the full control of TI or System.
For example, in Windows 10, it is often necessary to disable or stop WindowsDefender. (If you install a different antivirus or temporarily stop WindowsDefender services when executing scripts from your installer, because this antivirus is paranoid ... [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinDefend] "Start"=dword:00000004 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WdNisDrv] "Start"=dword:00000004 Also, sometimes it is necessary to make ordinary user settings such as: disable Cloud Protection, Automatic submission of samples, etc. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Spynet] "SpyNetReporting"=dword:00000000 "SubmitSamplesConsent"=dword:00000000 All such registry keys cannot be listed ... And Microsoft increasingly protects the registry from the user ... ![]() |
![]() |
![]() |
![]() |
#14 | |
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 907
|
Quote:
![]() "Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
|
![]() |
![]() |
![]() |
#15 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
|
![]() |
![]() |
![]() |
#16 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
Regedit cannot take ownership of WinDefend nor Spynet. If Regedit can't do it, we can't do it.
Just to clarify, trying to set S-1-5-32-544 (BUILTIN\Administrators) as the owner of the Spynet key with SetNamedSecurityInfoW fails even though we have enabled both SE_RESTORE_NAME and SE_TAKE_OWNERSHIP_NAME in the process token. Which tricks are you currently using to bypass this security? See also: https://docs.microsoft.com/en-us/win...nership-in-c-- IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#17 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Registry key values for WindowsDefender change without problems when you run reg files as TrustedInstaller. (it is better to do this using special utilities such as devxexec.exe, RunAsTI.exe, PowerRun.exe, etc.)
Keys for WindowsDefender are an exception. Probably, I gave an unsuccessful example ... There shouldn't be any problems for full control detection for the rest of the registry keys. (I tested the key [HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ Control \ AGP] ) |
![]() |
![]() |
![]() |
#18 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
|
Ideally you should probably use transacted registry when doing evil things like this but it is a start at least:
PHP Code:
PHP Code:
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#19 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Great ! Anders, thanks a lot ! I will study and apply your coding magic.
|
![]() |
![]() |
![]() |
#20 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
I'm sorry, but I'm back to the damn registry keys in Windows 10 ...
A seemingly simple task is to determine the existence of a key in the registry. It is easy to determine whether there is such a key or not. The key is still the same: HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows Defender \ Spynet And one more : HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ WindowsSelfHost \ UI \ Visibility But the task was not solvable! What's the matter ? How do I solve this? code: |
![]() |
![]() |
![]() |
#21 |
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 907
|
Is = the same as == ? You used both in your ${If} statements.
"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
![]() |
![]() |
![]() |
#22 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
With other registry keys, this code is working normally. (Forgot to specify $ {registry :: unload})
The point is not in this code, but in the principle of determining the existence of keys that does not work ... |
![]() |
![]() |
![]() |
#23 |
Banned
Join Date: Feb 2021
Posts: 2
|
[*]Open the Registry Editor by running regedit.exe.[*]Navigate to the branch for which you want to modify the permissions.[*]Right-click on the branch, and choose Permissions…[*]Click the Advanced button.[*]In the Adv[/LIST]anced Security Settings dialog, note down the owner.
|
![]() |
![]() |
![]() |
#24 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
The owner in this case does not matter.
Here is an example with the owner of TrustedInstaller. The key is determined without problems. Working example: code: |
![]() |
![]() |
![]() |
#25 |
Senior Member
Join Date: Nov 2012
Posts: 165
|
Oops ... completely forgot about SetRegView 64.
|
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|