關於xp cmdshell的注意事項

2021-04-24 10:14:28 字數 1104 閱讀 1634

一、mssql2000的master本身沒有擴充套件儲存過程xp_cmdshell,所以要建立一下,然後就看直接使用了:

sqlcommand.commandtext ="use master;"+

"if not exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[xp_cmdshell]') and objectproperty(id, n'i***tendedproc') = 1)" +

"exec sp_addextendedproc 'xp_cmdshell', 'xplog70.dll'";

sqlcommand.executenonquery();

二、mssql2005的master本身就有擴充套件儲存過程xp_cmdshell,所以不用建立,但需要啟用這個高階功能:

sqlcommand.commandtext = "exec sp_configure 'show advanced options', 1;/r/n" +

"reconfigure /r/n" +

"exec sp_configure 'xp_cmdshell', 1; /r/n" +

"reconfigure /r/n";

sqlcommand.executenonquery();

這個是關閉:

sqlcommand.commandtext = "exec sp_configure 'show advanced options', 1;/r/n" +

"reconfigure /r/n" +

"exec sp_configure 'xp_cmdshell', 0; /r/n" +

"reconfigure /r/n";

sqlcommand.executenonquery();

三、所以要判斷mssql的版本:

sqlcommand.commandtext = "select  serverproperty('productversion')";

string aa = sqlcommand.executescalar().tostring();

if (aa.substring(0, 1) != "8")

{

關於xp cmdshell 。。注意安全!

昨天看了儲存過程的一點東西,其中就說到了xp cmdshell 這個東西,以前只是知道黑客能通過mssql的漏洞來入侵你的系統,不是太明白。當知道了xp cmdshell 的強大之後,試了一下,有點開竅了,下面是這方面的一點東西。xp cmdshell可以讓系統管理員以作業系統命令列直譯器的方式執行...

突破SQL的xp cmdshell恢復終極方法

sql server 2005下開啟xp cmdshell的辦法 以下是引用片段 exec sp configure show advanced options 1 reconfigure exec sp configure xp cmdshell 1 reconfigure sql2005開啟 o...

在使用命令xp cmdshell的時候需要設定許可權

mssql2005 如何啟用xp cmdshell 預設情況下,sql server2005安裝完後,xp cmdshell是禁用的 可能是安全考慮 如果要使用它,可按以下步驟 允許配置高階選項 exec sp configure show advanced options 1 go 重新配置 re...