asp.net sql防注入代码

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestSQLInjection.aspx.cs" Inherits="SQLInjection_TestSQLInjection" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
   
    </div>
    <asp:Button ID="btnPost" runat="server" onclick="btnPost_Click"
        Text="获取Post数据" />
    <asp:Button ID="btnGet" runat="server" onclick="Button2_Click" Text="获取Get数据" />
    </form>
</body>
</html>
 
 testsqlinjection.aspx.cs文件
 
 using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class SQLInjection_TestSQLInjection : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }   

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("TestSQLInjection.aspx?Id=100&cc=200&dd=300");
    }

    protected void btnPost_Click(object sender, EventArgs e)
    {
       
    }
}

时间: 2024-11-03 00:28:21

asp.net sql防注入代码的相关文章

php 过滤特殊字符及sql防注入代码

php 过滤特殊字符及sql防注入代码 <?php //方法一 //过滤',",sql语名 addslashes(); //方法二,去除所有html标签 strip_tags(); //方法三过滤可能产生代码 function php_sava($str) {     $farr = array(         "/s+/",                                                                        

ASP最新SQL防注入过滤涵数

sql|防注入 Function Checkstr(Str) If Isnull(Str) Then CheckStr = "" Exit Function End If Str = Replace(Str,Chr(0),"", 1, -1, 1) Str = Replace(Str, """", """, 1, -1, 1) Str = Replace(Str,"<",

asp.net最强sql防注入代码

SqlConnection conn = new SqlCheck().oconn();       // 第2种调用的方法  SqlCheck.JK1986_CheckSql();         string osql = "select count(*) from admin";         SqlCommand ocmd = new SqlCommand(osql, conn); using System; using System.Data; using System.C

sql防注入代码(1/2)

以下代码生成的sql语句是曾对sql server 2005以上版本的,希望这些代码对大家有用 public class pagerquery { private int _pageindex; private int _pagesize = 20; private string _pk; private string _fromclause; private string _groupclause; private string _selectclause; private string _s

asp 完美sql防注入实例程序

Dim Query_Badword,Form_Badword,i,Err_Message,Err_Web,name '------定义部份  头---------------------------------------------------------------------- Err_Message = 1  '处理方式:1=提示信息,2=转向页面,3=先提示再转向 Err_Web = "Err.Asp" '出错时转向的页面 Query_Badword="'∥and∥

php sql 防注入代码

<?php教程 //要过滤的非法字符 $ArrFiltrate=array("'",";","union"); //出错后要跳转的url,不填则默认前一页 $StrGoUrl=""; //是否存在数组中的值 function FunStringExist($StrFiltrate,$ArrFiltrate){ foreach ($ArrFiltrate as $key=>$value){ if (eregi($va

ASP通用防注入代码.杜绝SQL注入隐患.提升网站安全

ASP通用防注入代码.杜绝SQL注入隐患.提升网站安全 <% '''''''''''''''''''''''''''''''''''''''''''''''' 'ASP通用防注入代码 '您可以把该代码COPY到头文件中.也可以单独作 '为一个文件存在,每次调用使用 '作者:y3gu - 2005-7-29 '''''''''''''''''''''''''''''''''''''''''''''''' Dim GetFlag Rem(提交方式) Dim ErrorSql Rem(非法字符) Di

asp sql超级防注入代码

asp sql超级防注入代码 <%Function Safe(str) Dim s_BadStr, n, i s_BadStr = "' &<>?%,;)`~!@#$^*{}[]|/+-="&Chr(34)&Chr(9)&Chr(32) n = Len(s_BadStr) Safe = True For i = 1 To n If Instr(str, Mid(s_BadStr, i, 1)) > 0 Then Safe = Fa

asp get post sql防注入函数

asp get post sql防注入函数 '----实现get请求的注入的拦截----- dim sql_injdata,Sql_Inj,SQL_Get,Sql_Post,Sql_DATA SQL_injdata = "'|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare" SQL_inj = split(SQL_Injdata,"|") If R