public void JK1986_CheckSql()
{
string jk1986_sql = "exec夢select夢drop夢alter夢exists夢union夢and夢or夢xor夢order夢mid夢asc夢execute夢xp_cmdshell夢insert夢update夢delete夢join夢declare夢char夢sp_oacreate夢wscript.shell夢xp_regwrite夢'夢;夢--夢%";
string[] jk_sql = jk1986_sql.Split('夢');
foreach (string jk in jk_sql)
{
// -----------------------防 Post 注入-----------------------
if (Page.Request.Form != null)
{
for (int k = 0; k < Page.Request.Form.Count; k++)
{
string getsqlkey = Page.Request.Form.Keys[k];
string getip;
if (Page.Request.Form[getsqlkey].ToLower().Contains(jk) == true)
{
Response.Write("<script Language=JavaScript>alert('ASP.NET( C#版本 )站长网提示您,请勿提交非法字符!↓\\n\\nBlog \\n\\nBy:Jack');</" + "script>");
Response.Write("非法操作!系统做了如下记录 ↓" + "<br>");
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null )
{
getip = this.Page.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
}
else
{
getip = Page.Request.ServerVariables["REMOTE_ADDR"];
}
Response.Write("操 作 I P :" + getip + "<br>");
Response.Write("操 作 时 间:" + DateTime.Now.ToString() + "<br>");
Response.Write("操 作 页 面:" + Page.Request.ServerVariables["URL"] + "<br>");
Response.Write("提 交 方 式:P O S T " + "<br>");
Response.Write("提 交 参 数:" + jk + "<br>");
Response.Write("提 交 数 据:" + Page.Request.Form[getsqlkey].ToLower() + "<br>");
Response.End();
}
}
}
// -----------------------防 GET 注入-----------------------
if (Page.Request.QueryString != null)
{
for (int k = 0; k < Page.Request.QueryString.Count; k++)
{
string getsqlkey = Page.Request.QueryString.Keys[k];
string getip;
if (Page.Request.QueryString[getsqlkey].ToLower().Contains(jk) == true)
{
Response.Write("<script Language=JavaScript>alert('ASP.NET( C#版本 )站长安全网提示您,请勿提交非法字符!↓\\n\\nBlog \\n\\nBy:Jack');</" + "script>");
Response.Write("非法操作!系统做了如下记录 ↓" + "<br>");
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null )
{
getip = this.Page.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
}
else
{
getip = Page.Request.ServerVariables["REMOTE_ADDR"];
}
Response.Write("操 作 I P :" + getip + "<br>");
Response.Write("操 作 时 间:" + DateTime.Now.ToString() + "<br>");
Response.Write("操 作 页 面:" + Page.Request.ServerVariables["URL"] + "<br>");
Response.Write("提 交 方 式:G E T " + "<br>");
Response.Write("提 交 参 数:" + jk + "<br>");
Response.Write("提 交 数 据:" + Page.Request.QueryString[getsqlkey].ToLower() + "<br>");
Response.End();
}
}
}
// -----------------------防 Cookies 注入-----------------------
if (Page.Request.Cookies != null)
{
for (int k = 0; k < Page.Request.Cookies.Count; k++)
{
string getsqlkey = Page.Request.Cookies.Keys[k];
string getip;
if (Page.Request.Cookies[getsqlkey].Value.ToLower().Contains(jk) == true)
{
Response.Write("<script Language=JavaScript>alert('ASP.NET( C#版本 )站长安全网提示您,请勿提交非法字符!↓\\n\\nBlog \\n\\nBy:Jack');</" + "script>");
Response.Write("非法操作!系统做了如下记录 ↓" + "<br>");
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null )
{
getip = this.Page.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
}
else
{
getip = Page.Request.ServerVariables["REMOTE_ADDR"];
}
Response.Write("操 作 I P :" + getip + "<br>");
Response.Write("操 作 时 间:" + DateTime.Now.ToString() + "<br>");
Response.Write("操 作 页 面:" + Page.Request.ServerVariables["URL"] + "<br>");
Response.Write("提 交 方 式: Cookies " + "<br>");
Response.Write("提 交 参 数:" + jk + "<br>");
Response.Write("提 交 数 据:" + Page.Request.Cookies[getsqlkey].Value.ToLower() + "<br>");
Response.End();
}
}
}
}
}