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;
}
}
}