SQL Server contains several extended stored procedures that can access the system registry. However, these extended stored procedures are not made public,
These stored procedures are available in SQL Server 7.0 and are retained in SQL Server 2000 and may be deleted later.
The ability to access the system registry in the current SQL Server version, and many people use SQL Server to attack the system,
These extended stored procedures are often used, so it is best to disable them in SQL Server.
Xp_regenumvalues returns all key values in the form of multiple Record Sets
Usage:
Xp_regenumvalues registry Root Key, subkey
For example, you want to see all the key values of HKEY_LOCAL_MACHINE/software/Microsoft/Windows/CurrentVersion/run:
Use master
Exec xp_regenumvalues 'HKEY _ LOCAL_MACHINE ', 'Software/Microsoft/Windows/CurrentVersion/run'
Xp_regread returns the specified key value
Usage:
Xp_regread Root Key, subkey, key value name
Use master
Exec xp_regread 'HKEY _ LOCAL_MACHINE ', 'Software/Microsoft/Windows/currentversion', 'commonfilesdir'
Xp_regwrite write to the Registry
Usage:
Xp_regwrite Root Key, subkey, Value Name, value type, Value
Use master
Exec xp_regwrite 'HKEY _ LOCAL_MACHINE ', 'Software/Microsoft/Windows/currentversion', 'testvaluename', 'reg _ SZ ', 'Hello'
Note that there are two value types: REG_SZ and REG_DWORD.
Xp_regdeletevalue delete a value
Usage:
Xp_regdeletevalue Root Key, subkey, Value Name
Use master
Exec xp_regdeletevalue 'HKEY _ LOCAL_MACHINE ', 'Software/Microsoft/Windows/currentversion', 'testvaluename'
Xp_regdeletekey: delete key, including all values under this key
Usage:
Use master
Xp_regdeletekey 'HKEY _ LOCAL_MACHINE ', 'Software/Microsoft/Windows/CurrentVersion/testkey'