sql注入數(shù)據(jù)庫(kù)修復(fù)的兩種實(shí)例方法
1.第一種情況是 需要將指定的 注入字符串全部替換掉(僅替換注入的字符串為空)
declare @delStr nvarchar(500)
set @delStr='<script src=http://www.dbjr.com.cn/js/common.js></script>' --這里被注入的字段串
/****************************************/
/**********以下為操作實(shí)體************/
set nocount on
declare @tableName nvarchar(100),@columnName nvarchar(100),@tbID int,@iRow int,@iResult int
declare @sql nvarchar(2000)
set @iResult=0
declare cur cursor for
select name,id from sysobjects where xtype='U'
open cur
fetch next from cur into @tableName,@tbID
while @@fetch_status=0
begin
declare cur1 cursor for
select name from syscolumns where xtype in (231,167,239,175, 35, 99) and id=@tbID
open cur1
fetch next from cur1 into @columnName
while @@fetch_status=0
begin
set @sql='update [' + @tableName + '] set ['+ @columnName +']= SUBSTRING([' + @columnName + '],' + '1, PATINDEX( ''%' + @delStr + '%'', [' + @columnName + '])-1) + ' + 'SUBSTRING([' + @columnName + '], PATINDEX( ''%' + @delStr + '%'', [' + @columnName + ']) + ' + 'len(''' + @delStr + ''') , datalength([' + @columnName + '])) where ['+@columnName+'] like ''%'+@delStr+'%'''
exec sp_executesql @sql
set @iRow=@@rowcount
set @iResult=@iResult+@iRow
if @iRow>0
begin
print '表:'+@tableName+',列:'+@columnName+'被更新'+convert(varchar(10),@iRow)+'條記錄;'
end
fetch next from cur1 into @columnName
end
close cur1
deallocate cur1
fetch next from cur into @tableName,@tbID
end
print '數(shù)據(jù)庫(kù)教程共有'+convert(varchar(10),@iResult)+'條記錄被更新!!!'
close cur
deallocate cur
set nocount off
2.第二種是 需要將注入到表中起始位置到最后都刪掉。(此種方法直接找到注入的起始位置,后面的全部刪掉)
--恢復(fù)被注入數(shù)據(jù)庫(kù)
--2013-09-26
declare @delStr nvarchar(500)
set @delStr='</title><style>.' --被注入的字段串的開(kāi)始采樣,從此位置后面的數(shù)據(jù)都為注入數(shù)據(jù)
/**********以下為操作實(shí)體************/
set nocount on
declare @tableName nvarchar(100),@columnName nvarchar(100),@tbID int,@iRow int,@iResult int
declare @sql nvarchar(2000)
set @iResult=0
declare cur cursor for
select name,id from sysobjects where xtype='U'
open cur
fetch next from cur into @tableName,@tbID
while @@fetch_status=0
begin
declare cur1 cursor for
select name from syscolumns where xtype in (231,167,239,175, 35, 99) and id=@tbID
open cur1
fetch next from cur1 into @columnName
while @@fetch_status=0
begin
set @sql='update [' + @tableName + '] set ['+ @columnName +']=
SUBSTRING([' + @columnName + '],1, PATINDEX( ''%' + @delStr + '%'', [' + @columnName + '])-1) where ['+@columnName+'] like ''%'+@delStr+'%'''
exec sp_executesql @sql
set @iRow=@@rowcount
set @iResult=@iResult+@iRow
if @iRow>0
begin
print '表:'+@tableName+',列:'+@columnName+'被更新'+convert(varchar(10),@iRow)+'條記錄;'
end
fetch next from cur1 into @columnName
end
close cur1
deallocate cur1
fetch next from cur into @tableName,@tbID
end
print '數(shù)據(jù)庫(kù)教程共有'+convert(varchar(10),@iResult)+'條記錄被更新!!!'
close cur
deallocate cur
set nocount off
- 淺談三種數(shù)據(jù)庫(kù)的?SQL?注入
- 數(shù)據(jù)庫(kù)之SQL注入原理以及過(guò)程的簡(jiǎn)單介紹
- 一個(gè)簡(jiǎn)單的后臺(tái)與數(shù)據(jù)庫(kù)交互的登錄與注冊(cè)[sql注入處理、以及MD5加密]
- Mysql數(shù)據(jù)庫(kù)使用concat函數(shù)執(zhí)行SQL注入查詢
- 數(shù)據(jù)庫(kù)SqlParameter 的插入操作,防止sql注入的實(shí)現(xiàn)代碼
- SQL數(shù)據(jù)庫(kù)的高級(jí)sql注入的一些知識(shí)
- 數(shù)據(jù)庫(kù)中的內(nèi)容字段被掛馬的替換方法 SQL注入
- ASP+MSSQL2000 數(shù)據(jù)庫(kù)被批量注入后的解決方法
- sql注入數(shù)據(jù)庫(kù)原理詳情介紹
相關(guān)文章
一個(gè)函數(shù)解決SQLServer中bigint 轉(zhuǎn) int帶符號(hào)時(shí)報(bào)錯(cuò)問(wèn)題
這篇文章主要介紹了解決SQLServer中bigint 轉(zhuǎn) int帶符號(hào)時(shí)報(bào)錯(cuò)問(wèn)題的函數(shù),需要的朋友可以參考下2014-08-08判斷數(shù)據(jù)庫(kù)表是否存在以及修改表名的方法
本文為大家詳細(xì)介紹下如何判斷數(shù)據(jù)庫(kù)表是否存在以及修改表名,感興趣的朋友可以參考下,希望對(duì)大家有所幫助2013-09-09詳解partition by和group by對(duì)比
這篇文章主要介紹了詳解partition by和group by對(duì)比,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09數(shù)據(jù)庫(kù)表的創(chuàng)建、管理和數(shù)據(jù)操作(實(shí)驗(yàn)一)
這篇文章主要介紹了數(shù)據(jù)庫(kù)中表的創(chuàng)建、管理和數(shù)據(jù)操作,感興趣的小伙伴可以參考一下2015-08-08企業(yè)管理器備份和還原SQL Server數(shù)據(jù)庫(kù)
本文我們主要介紹了利用SQL Server數(shù)據(jù)庫(kù)的企業(yè)管理器來(lái)備份和還原數(shù)據(jù)庫(kù)的方法以及每日自動(dòng)備份數(shù)據(jù)庫(kù)的設(shè)置,希望能夠?qū)δ兴鶐椭?/div> 2015-08-08SqlServer2012中First_Value函數(shù)簡(jiǎn)單分析
SQL SERVER 2012 T-SQL新增幾個(gè)聚合函數(shù): FIRST_VALUE LAST_VALUE LEAD LAG,今天我們首先來(lái)簡(jiǎn)單分析下FIRST_VALUE,希望對(duì)大家有所幫助,能夠盡快熟悉這個(gè)聚合函數(shù)2014-08-08sql存儲(chǔ)過(guò)程實(shí)例--動(dòng)態(tài)根據(jù)表數(shù)據(jù)復(fù)制一個(gè)表的數(shù)據(jù)到另一個(gè)表
這篇文章主要介紹了sql存儲(chǔ)過(guò)程實(shí)例--動(dòng)態(tài)根據(jù)表數(shù)據(jù)復(fù)制一個(gè)表的數(shù)據(jù)到另一個(gè)表的相關(guān)資料,需要的朋友可以參考下2017-10-10最新評(píng)論