您现在的位置是:网站首页> 编程资料编程资料
sqlserver 数据库被注入解决方案_MsSql_
2023-05-26
312人已围观
简介 sqlserver 数据库被注入解决方案_MsSql_
复制代码 代码如下:
declare @delStr nvarchar(500)
set @delStr='' --这里被注入的字段串
/****************************************/
/**********以下为操作实体************/
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 '数据库共有'+convert(varchar(10),@iResult)+'条记录被更新!!!'
close cur
deallocate cur
set nocount off
相关内容
- win2003 安装 sqlserver 2005的方法_MsSql_
- sql 版本详解 让你认识跟sql2000的区别_MsSql_
- SQLSERVER 时间格式大全_MsSql_
- sqlserver replace函数 批量替换数据库中指定字段内指定字符串参考方法_MsSql_
- sql 中 case when 语法使用方法_MsSql_
- 将MS SQL SERVER数据库运行在普通用户(独立用户)状态下的设置方法终结篇_MsSql_
- SQLServer 优化SQL语句 in 和not in的替代方案_MsSql_
- SQL Server 2005/2008 用户数据库文件默认路径和默认备份路径修改方法_MsSql_
- SQL 时间格式化函数_MsSql_
- 全国省市区县最全最新数据表(数据来源谷歌)_MsSql_
