易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL注入攻击防范技巧


SQL注入攻击防范技巧
一般的SQL注入攻击都是通过构建一条复杂的sql语句,
通过网页漏洞来执行sql语句,达到攻击数据库的目的。
如通过文章ID来查询某一篇文章的网页,
通常采用的sql语句为:
sql="select top 1 * from articles where articId="&request("id")
那么可以简单地构建一条攻击语句:
传入id变量的值为:1; select getDate(); --
从而构建了一条新的sql语句:
select top 1 * from articles where articId=1;
select getDate(); --
虽然这条语句并不能对数据库产生任何负面影响,
但是其它的攻击语句也是这样通过添加语句分隔符;和注释符号--来组成的。
我们的防范技巧,对所有可以提交传入的变量进行处理:
1、int类型的数据,如上例中的id,则使用以下方法处理:
   <%
 on error resume next
 id = CInt(request("id"))
   %>
2、字符串类型的数据,则进行常见的标点符号过滤处理:
   <%
 str = request("str")
 str = replace(str, "´", "") ´将单引号字符过滤掉
 str = replace(str, ";", "") ´将分号过滤掉
 ´...
   %>
   其他字符不一一枚举,你可以写一个字符过滤的函数,过滤一些在你的网站当中
   并不常用的有危险性的符号;也可以采用正则表达式来进行过滤;


相关文档:

SQL语句PART8

PairWise subquery:
e.g.:
select * from wf_docsort where (ndocsortid,nmoduleinfoid)  in (select ndocsortid, nmoduleinfoid from wf_docsort where instr(cname,'文')>0)
the above sql is the same function as:
select * from wf_docsort where ndocsortid = (select ndocsortid from wf_docsort where ......

SQL Server系统视图


--> Title  : SQL Server系统视图
--> Author : wufeng4552
--> Date   : 2009-10-28
 
目录视图
目录视图返回 SQL Server 数据库引擎使用的信息。建议您使用目录视图这一最常用的目录元数据界面,它可为您提供最有效的方法来获取、转换并显示此信息的自定义形式。所有用户可用目录元 ......

SQL连接类

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace DAL
{ ......

sql server中in和exists的小区别 oracle未测试

in 的话, 如果是null 就不比较了,既不是in 也不是 not in
exists的话 因为用 = 加在条件里比较了,所以 null 是 not exists
select *
from pricetemp
where cast(商品コード as varchar(10))not in(
           select shohin_cd
  &nbs ......

asp.net从sql server2005中查询数据

 首先要添加
using System.Data;
using System.Data.SqlClient;    
接下来:
          SqlConnection conn = new SqlConnection("server=QLPC\\SQL2005;uid=sa;pwd=(你的密码);database=(你的数据表)");     &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号