sqlserver存儲過程加密
發布時間: 2023-06-05 03:58:49
比較簡單的做法是數據在存入資料庫之前用c#進行加密,然後再存入資料庫,讀取數據之後,用相應的解密方法對數據進行解密。
但是,如果你一定要在存儲過程中加密的話,可以使用c#創建好對應的加密解密方法,然後生成一個加解密的類庫dll,在sqlserver中引入該dll中的加密方法進行加密(Sqlserver調用dll的方法sqlserver調用dll),程序中可以直接調用該dll中的解密方法,也可以把解密方法直接寫在程序中。
Ⅱ 怎麼破解sqlserver加密的存儲過程
在另外一台電腦上裝資料庫,然後將加密所在存儲的資料庫恢復上去即可。
Ⅲ 道與魔:SqlServer存儲過程/函數加/解密
存儲過程 存儲函數的加密 WITH ENCRYPTION<! [if !supportLineBreakNewLine] ><! [endif] >CREATE procere dbo sp_XML_main@table_name nvarchar( )= @dirname nvarchar( )= WITH ENCRYPTIONasbegin endgo存儲過程 存儲函數的解密(以下是一位絕世高人編寫的代碼)if exists (select * from dbo sysobjects where id = object_id(N [dbo] [sp_decrypt] ) and OBJECTPROPERTY(id N IsProcere ) = )drop procere [dbo] [sp_decrypt]GO/* 破解函談氏消數 過程 觸發器 視圖 僅限於SQLSERVER 作者:J All rights reserved*//* 調用示例 解密指定存儲過程exec sp_decrypt AppSP_test 對所有的存儲過程解密declare tb cursor forselect name from sysobjects where xtype= P and status> and name<> sp_decrypt declare @name sysnameopen tbfetch next from tb into @namewhile @@fetch_status= beginprint /* 存儲過程 [ +@name+ ] */ exec sp_decrypt @namefetch next from tb into @nameendclose tbdeallocate tb */if exists (select * from dbo sysobjects where id = object_id(N [dbo] [SP_DECRYPT] ) and OBJECTPROPERTY(id N IsProcere ) = )drop procere [dbo] [SP_DECRYPT]GOCREATE PROCEDURE sp_decrypt(@objectName varchar( ))ASbeginset nocount on 破解位元組不受限制 適用於SQLSERVER 存儲過程 函數 視圖 觸發器 修正上一版視圖觸發器不能正確解密錯誤 發現有錯 請E_MAIL begin trandeclare @objectname varchar( ) @varbin varbinary( )declare @sql nvarchar( ) @sql varchar( ) @sql nvarchar( ) @sql nvarchar( )DECLARE @OrigSpText nvarchar( ) @OrigSpText nvarchar( ) @OrigSpText nvarchar( ) @resultsp nvarchar( )declare @i int @status int @type varchar( ) @parentid intdeclare @colid int @n int @q int @j int @k int @encrypted int @number int核鋒select @type=xtype @parentid=parent_obj from sysobjects where id=object_id(@ObjectName)含知create table #temp(number int colid int ctext varbinary( ) encrypted int status int)insert #temp SELECT number colid ctext encrypted status FROM sy *** ents WHERE id = object_id(@objectName)select @number=max(number) from #tempset @k= while @k<=@numberbeginif exists(select from sy *** ents where id=object_id(@objectname) and number=@k)beginif @type= P set @sql =(case when @number> then ALTER PROCEDURE + @objectName + ; +rtrim(@k)+ WITH ENCRYPTION AS else ALTER PROCEDURE + @objectName+ WITH ENCRYPTION AS end)if @type= TR begindeclare @parent_obj varchar( ) @tr_parent_xtype varchar( )select @parent_obj=parent_obj from sysobjects where id=object_id(@objectName)select @tr_parent_xtype=xtype from sysobjects where id=@parent_objif @tr_parent_xtype= V beginset @sql = ALTER TRIGGER +@objectname+ ON +OBJECT_NAME(@parentid)+ WITH ENCRYPTION INSTERD OF INSERT AS PRINT endelsebeginset @sql = ALTER TRIGGER +@objectname+ ON +OBJECT_NAME(@parentid)+ WITH ENCRYPTION FOR INSERT AS PRINT endendif @type= FN or @type= TF or @type= IF set @sql =(case @type when TF then ALTER FUNCTION + @objectName+ (@a char( )) returns @b table(a varchar( )) with encryption as begin insert @b select @a return end when FN then ALTER FUNCTION + @objectName+ (@a char( )) returns char( ) with encryption as begin return @a end when IF then ALTER FUNCTION + @objectName+ (@a char( )) returns table with encryption as return select @a as a end)if @type= V set @sql = ALTER VIEW +@objectname+ WITH ENCRYPTION AS SELECT as f set @q=len(@sql )set @sql =@sql +REPLICATE( @q)select @sql =REPLICATE( )set @sql = exec(@sql select @colid=max(colid) from #temp where number=@kset @n= while @n<=CEILING( *(@colid )/ ) and len(@sQL )<= beginset @sql =@sql + +@ set @n=@n+ endset @sql =@sql + ) exec sp_executesql @sql N @sql nvarchar( ) @ varchar( ) @sql =@sql @=@sql endset @k=@k+ endset @k= while @k<=@numberbeginif exists(select from sy *** ents where id=object_id(@objectname) and number=@k)beginselect @colid=max(colid) from #temp where number=@kset @n= while @n<=@colidbeginselect @OrigSpText =ctext @encrypted=encrypted @status=status FROM #temp WHERE colid=@n and number=@kSET @OrigSpText =(SELECT ctext FROM sy *** ents WHERE id=object_id(@objectName) and colid=@n and number=@k)if @n= beginif @type= P SET @OrigSpText =(case when @number> then CREATE PROCEDURE + @objectName + ; +rtrim(@k)+ WITH ENCRYPTION AS else CREATE PROCEDURE + @objectName + WITH ENCRYPTION AS end)if @type= FN or @type= TF or @type= IF SET @OrigSpText =(case @type when TF then CREATE FUNCTION + @objectName+ (@a char( )) returns @b table(a varchar( )) with encryption as begin insert @b select @a return end when FN then CREATE FUNCTION + @objectName+ (@a char( )) returns char( ) with encryption as begin return @a end when IF then CREATE FUNCTION + @objectName+ (@a char( )) returns table with encryption as return select @a as a end)if @type= TR beginif @tr_parent_xtype= V beginset @OrigSpText = CREATE TRIGGER +@objectname+ ON +OBJECT_NAME(@parentid)+ WITH ENCRYPTION INSTEAD OF INSERT AS PRINT endelsebeginset @OrigSpText = CREATE TRIGGER +@objectname+ ON +OBJECT_NAME(@parentid)+ WITH ENCRYPTION FOR INSERT AS PRINT endendif @type= V set @OrigSpText = CREATE VIEW +@objectname+ WITH ENCRYPTION AS SELECT as f set @q= len(@OrigSpText )set @OrigSpText =@OrigSpText +REPLICATE( @q)endelsebeginSET @OrigSpText =REPLICATE( )endSET @i= SET @resultsp = replicate(N A (datalength(@OrigSpText ) / ))WHILE @i<=datalength(@OrigSpText )/ BEGINSET @resultsp = stuff(@resultsp @i NCHAR(UNICODE(substring(@OrigSpText @i )) ^ lishixin/Article/program/SQLServer/201311/21965
Ⅳ SQLSERVER存儲過程加密後,是不是任意版本都可以很容易解密
是的到目前為止,SQL Server所有版本的存儲過程的加密的機理都是一樣的,都可以被非常容易的破解,前提是,有讀取存儲過程的代碼的權。
要防止用戶得到SQL Server存儲過程的真實代碼,最簡單的做法就是只給執行權,不給查看權。
至於安裝在別人伺服器上的SQL Server資料庫中的存儲過程,想不讓別人看,那基本上是沒門兒的。
Ⅳ sqlserver 中怎麼樣給現有的資料庫加密。就是不想把自己資料庫的存儲過程等信息給其他人看到。
你把你的資料庫修改登錄時只能用用戶名和密碼登錄,不允許windows登錄,然後為他創建一個用戶,這個用戶賦予的許可權你自己選,你想讓他看什麼就給他許可權。不想就別給他賦許可權即可。
熱點內容