
SQL注入#region SQL注入
public static void SQLZ()
{
HttpContext.Current.Request.QueryString;
CheckSQLZ(HttpContext.Current.Request.QueryString);
}
private static void CheckSQLZ(System.Collections.Specialized.NameValueCollection qs)
{
if (qs.Count > 0)
{
for (int i = 0; i < qs.Count; i++)
{
if (!Z(qs[i].ToLower()))
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write("您好,SQL注入?");
HttpContext.Current.Response.End();
}
}
}
}
private static string[] al = ";|and|1=1|exec|insert|select|delete|update|like|count|chr|mid|master|or|truncate|char|declare|join".Split('|');
public static bool Z(string v)
{
if (v.Trim() != "")
{
foreach (string a in al)
{
if (v.IndexOf(a + " ") > -1 || v.IndexOf(" " + a) > -1)
{
return false;
}
}
}
return true;
}
#endregion