XP_CMDSHELL

In an effort to reduce the attack surface, in  SQL 2005 upwards, XP_CMDSHELL is disabled by default.

To enable XP_CMDSHELL, in SQL 2005 or 2008, the following script will work..

EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO

-- To enable xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO

EXEC sp_configure 'show advanced options', 0
GO
RECONFIGURE
GO

Before it can be enabled, you need to allow the advanced options to changed which is what the ‘show advanced options’ does. This is then disabled afterwards.

To disable it, change the 1 to a 0 as below :-

EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO

-- To disable xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 0
GO
RECONFIGURE
GO

EXEC sp_configure 'show advanced options', 0
GO
RECONFIGURE
GO

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.